Skip to content

Commit

Permalink
fix neard testnet to use shard_version = 0 instead of 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Min Zhang committed Aug 19, 2021
1 parent 1db0073 commit 2bb24a2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion integration-tests/src/runtime_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use testlib::runtime_utils::{add_test_contract, alice_account, bob_account};
pub const TEST_SHARD_UID: ShardUId = ShardUId { version: 1, shard_id: 0 };

pub fn get_runtime_and_trie() -> (Runtime, ShardTries, StateRoot) {
let mut genesis = Genesis::test_sharded(
let mut genesis = Genesis::test_sharded_new_version(
vec![alice_account(), bob_account(), "carol.near".parse().unwrap()],
3,
vec![3],
Expand Down
14 changes: 10 additions & 4 deletions integration-tests/tests/client/process_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,8 +1549,11 @@ fn test_gc_after_state_sync() {
fn test_process_block_after_state_sync() {
let epoch_length = 1024;
// test with shard_version > 0
let mut genesis =
Genesis::test_sharded(vec!["test0".parse().unwrap(), "test1".parse().unwrap()], 1, vec![1]);
let mut genesis = Genesis::test_sharded_new_version(
vec!["test0".parse().unwrap(), "test1".parse().unwrap()],
1,
vec![1],
);
genesis.config.epoch_length = epoch_length;
let mut chain_genesis = ChainGenesis::test();
chain_genesis.epoch_length = epoch_length;
Expand Down Expand Up @@ -2386,8 +2389,11 @@ fn test_refund_receipts_processing() {

let epoch_length = 5;
let min_gas_price = 10000;
let mut genesis =
Genesis::test_sharded(vec!["test0".parse().unwrap(), "test1".parse().unwrap()], 1, vec![1]);
let mut genesis = Genesis::test_sharded_new_version(
vec!["test0".parse().unwrap(), "test1".parse().unwrap()],
1,
vec![1],
);
genesis.config.epoch_length = epoch_length;
genesis.config.min_gas_price = min_gas_price;
// set gas limit to be small
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/nearcore/node_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn start_nodes(
let num_nodes = dirs.len();
let num_tracking_nodes = num_nodes - num_lightclient;
let seeds = (0..num_nodes).map(|i| format!("near.{}", i)).collect::<Vec<_>>();
let mut genesis = Genesis::test_sharded(
let mut genesis = Genesis::test_sharded_new_version(
seeds.iter().map(|s| s.parse().unwrap()).collect(),
num_validator_seats,
(0..num_shards).map(|_| num_validator_seats).collect(),
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/tests/nearcore/sync_state_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn sync_state_nodes_multishard() {
heavy_test(|| {
init_integration_logger();

let mut genesis = Genesis::test_sharded(
let mut genesis = Genesis::test_sharded_new_version(
vec![
"test1".parse().unwrap(),
"test2".parse().unwrap(),
Expand Down Expand Up @@ -259,7 +259,7 @@ fn sync_empty_state() {
heavy_test(|| {
init_integration_logger();

let mut genesis = Genesis::test_sharded(
let mut genesis = Genesis::test_sharded_new_version(
vec!["test1".parse().unwrap(), "test2".parse().unwrap()],
1,
vec![1, 1, 1, 1],
Expand Down
14 changes: 14 additions & 0 deletions nearcore/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,20 @@ impl Genesis {
accounts: Vec<AccountId>,
num_validator_seats: NumSeats,
num_validator_seats_per_shard: Vec<NumSeats>,
) -> Self {
let num_shards = num_validator_seats_per_shard.len() as NumShards;
Self::test_with_seeds(
accounts,
num_validator_seats,
num_validator_seats_per_shard,
ShardLayout::v0(num_shards, 0),
)
}

pub fn test_sharded_new_version(
accounts: Vec<AccountId>,
num_validator_seats: NumSeats,
num_validator_seats_per_shard: Vec<NumSeats>,
) -> Self {
let num_shards = num_validator_seats_per_shard.len() as NumShards;
Self::test_with_seeds(
Expand Down
2 changes: 1 addition & 1 deletion nearcore/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,7 @@ mod test {
acc.union(&x.iter().cloned().collect()).cloned().collect()
});
let validators_len = all_validators.len() as ValidatorId;
let mut genesis = Genesis::test_sharded(
let mut genesis = Genesis::test_sharded_new_version(
all_validators.into_iter().collect(),
validators_len,
validators.iter().map(|x| x.len() as ValidatorId).collect(),
Expand Down

0 comments on commit 2bb24a2

Please sign in to comment.