Skip to content

Commit

Permalink
fix(resharding): fix tests (#10314)
Browse files Browse the repository at this point in the history
This should fix a bunch of the nayduck tests. 

https://nayduck.near.org/#/run/3318
  • Loading branch information
wacban authored Dec 11, 2023
1 parent 9d0d7df commit fd724ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 82 deletions.
101 changes: 20 additions & 81 deletions integration-tests/src/tests/client/resharding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use near_primitives::utils::MaybeValidated;
use near_primitives::version::ProtocolFeature;
use near_primitives::version::PROTOCOL_VERSION;
use near_primitives::views::{ExecutionStatusView, FinalExecutionStatus, QueryRequest};
use near_primitives_core::checked_feature;
use near_primitives_core::num_rational::Rational32;
use near_store::flat::FlatStorageStatus;
use near_store::test_utils::{gen_account, gen_unique_accounts};
Expand Down Expand Up @@ -1000,26 +999,17 @@ fn test_shard_layout_upgrade_simple_v1_with_snapshot_enabled() {

#[test]
fn test_shard_layout_upgrade_simple_v2_seed_42() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_simple_impl(ReshardingType::V2, 42, false);
}
test_shard_layout_upgrade_simple_impl(ReshardingType::V2, 42, false);
}

#[test]
fn test_shard_layout_upgrade_simple_v2_seed_43() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_simple_impl(ReshardingType::V2, 43, false);
}
test_shard_layout_upgrade_simple_impl(ReshardingType::V2, 43, false);
}

#[test]
fn test_shard_layout_upgrade_simple_v2_seed_44() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_simple_impl(ReshardingType::V2, 44, false);
}
test_shard_layout_upgrade_simple_impl(ReshardingType::V2, 44, false);
}

/// In this test we are checking whether we are properly deleting trie state and flat state
Expand Down Expand Up @@ -1067,10 +1057,7 @@ fn test_shard_layout_upgrade_gc() {

#[test]
fn test_shard_layout_upgrade_gc_v2() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_gc_impl(ReshardingType::V2, 44);
}
test_shard_layout_upgrade_gc_impl(ReshardingType::V2, 44);
}

const GAS_1: u64 = 300_000_000_000_000;
Expand Down Expand Up @@ -1350,30 +1337,21 @@ fn test_shard_layout_upgrade_cross_contract_calls_v1() {
// This test case tests postponed receipts and delayed receipts
#[test]
fn test_shard_layout_upgrade_cross_contract_calls_v2_seed_42() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V2, 42);
}
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V2, 42);
}

// Test cross contract calls
// This test case tests postponed receipts and delayed receipts
#[test]
fn test_shard_layout_upgrade_cross_contract_calls_v2_seed_43() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V2, 43);
}
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V2, 43);
}

// Test cross contract calls
// This test case tests postponed receipts and delayed receipts
#[test]
fn test_shard_layout_upgrade_cross_contract_calls_v2_seed_44() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V2, 44);
}
test_shard_layout_upgrade_cross_contract_calls_impl(ReshardingType::V2, 44);
}

fn test_shard_layout_upgrade_incoming_receipts_impl(
Expand Down Expand Up @@ -1433,26 +1411,17 @@ fn test_shard_layout_upgrade_incoming_receipts_v1() {

#[test]
fn test_shard_layout_upgrade_incoming_receipts_v2_seed_42() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V2, 42);
}
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V2, 42);
}

#[test]
fn test_shard_layout_upgrade_incoming_receipts_v2_seed_43() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V2, 43);
}
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V2, 43);
}

#[test]
fn test_shard_layout_upgrade_incoming_receipts_v2_seed_44() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V2, 44);
}
test_shard_layout_upgrade_incoming_receipts_impl(ReshardingType::V2, 44);
}

// Test cross contract calls
Expand Down Expand Up @@ -1555,78 +1524,51 @@ fn test_shard_layout_upgrade_missing_chunks_high_missing_prob_v1() {

#[test]
fn test_shard_layout_upgrade_missing_chunks_low_missing_prob_v2_seed_42() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.1, 42);
}
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.1, 42);
}

#[test]
fn test_shard_layout_upgrade_missing_chunks_low_missing_prob_v2_seed_43() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.1, 43);
}
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.1, 43);
}

#[test]
fn test_shard_layout_upgrade_missing_chunks_low_missing_prob_v2_seed_44() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.1, 44);
}
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.1, 44);
}

// V2, mid missing prob

#[test]
fn test_shard_layout_upgrade_missing_chunks_mid_missing_prob_v2_seed_42() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.5, 42);
}
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.5, 42);
}

#[test]
fn test_shard_layout_upgrade_missing_chunks_mid_missing_prob_v2_seed_43() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.5, 43);
}
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.5, 43);
}

#[test]
fn test_shard_layout_upgrade_missing_chunks_mid_missing_prob_v2_seed_44() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.5, 44);
}
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.5, 44);
}

// V2, high missing prob

#[test]
fn test_shard_layout_upgrade_missing_chunks_high_missing_prob_v2_seed_42() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.9, 42);
}
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.9, 42);
}

#[test]
fn test_shard_layout_upgrade_missing_chunks_high_missing_prob_v2_seed_43() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.9, 43);
}
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.9, 43);
}

#[test]
fn test_shard_layout_upgrade_missing_chunks_high_missing_prob_v2_seed_44() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.9, 44);
}
test_shard_layout_upgrade_missing_chunks(ReshardingType::V2, 0.9, 44);
}

#[test]
Expand Down Expand Up @@ -1726,10 +1668,7 @@ fn test_shard_layout_upgrade_error_handling_v1() {

#[test]
fn test_shard_layout_upgrade_error_handling_v2() {
// TODO(resharding) remove those checks once rolled out
if checked_feature!("stable", SimpleNightshadeV2, PROTOCOL_VERSION) {
test_shard_layout_upgrade_error_handling_impl(ReshardingType::V2, 42, false);
}
test_shard_layout_upgrade_error_handling_impl(ReshardingType::V2, 42, false);
}

// TODO(resharding) add a test with missing blocks
Expand Down
4 changes: 3 additions & 1 deletion pytest/lib/resharding_lib.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# A library with the common constants and functions for testing resharding.

# TODO(resharding) The resharding V2 is now stabilized so the V1 code is no
# longer exercised and can be removed.
V1_PROTOCOL_VERSION = 48
V2_PROTOCOL_VERSION = 135
V2_PROTOCOL_VERSION = 64

V0_SHARD_LAYOUT = {
"V0": {
Expand Down

0 comments on commit fd724ad

Please sign in to comment.