@Test public void createFromJsonWithAllocs() throws Exception { final GenesisState genesisState = GenesisState.fromJson( Resources.toString(GenesisStateTest.class.getResource("genesis1.json"), Charsets.UTF_8), MainnetProtocolSchedule.create()); final BlockHeader header = genesisState.getBlock().getHeader(); assertThat(header.getStateRoot()) .isEqualTo( Hash.fromHexString( "0x92683e6af0f8a932e5fe08c870f2ae9d287e39d4518ec544b0be451f1035fd39")); assertThat(header.getTransactionsRoot()).isEqualTo(Hash.EMPTY_TRIE_HASH); assertThat(header.getReceiptsRoot()).isEqualTo(Hash.EMPTY_TRIE_HASH); assertThat(header.getOmmersHash()).isEqualTo(Hash.EMPTY_LIST_HASH); assertThat(header.getExtraData()).isEqualTo(BytesValue.EMPTY); assertThat(header.getParentHash()).isEqualTo(Hash.ZERO); final DefaultMutableWorldState worldState = new DefaultMutableWorldState( new KeyValueStorageWorldStateStorage(new InMemoryKeyValueStorage())); genesisState.writeStateTo(worldState); final Account first = worldState.get(Address.fromHexString("0x0000000000000000000000000000000000000001")); final Account second = worldState.get(Address.fromHexString("0x0000000000000000000000000000000000000002")); assertThat(first).isNotNull(); assertThat(first.getBalance().toLong()).isEqualTo(111111111L); assertThat(second).isNotNull(); assertThat(second.getBalance().toLong()).isEqualTo(222222222L); }
mock(PrivateTransactionHandler.class); stateArchive = createInMemoryWorldStateArchive(); GENESIS_CONFIG.writeStateTo(stateArchive.getMutable(Hash.EMPTY_TRIE_HASH));
genesisState.writeStateTo(worldStateArchive.getMutable(Hash.EMPTY_TRIE_HASH));
final WorldStateArchive worldArchive = createInMemoryWorldStateArchive(); genesisState.writeStateTo(worldArchive.getMutable()); final ProtocolContext<Void> protocolContext = new ProtocolContext<>(blockchain, worldArchive, null);
genesisState.writeStateTo(worldStateArchive.getMutable(Hash.EMPTY_TRIE_HASH));
genesisState.writeStateTo(worldStateArchive.getMutable(Hash.EMPTY_TRIE_HASH));
genesisState.writeStateTo(worldStateArchive.getMutable(Hash.EMPTY_TRIE_HASH));
createInMemoryBlockchain(genesisState.getBlock(), blockHashFunction); final WorldStateArchive worldStateArchive = createInMemoryWorldStateArchive(); genesisState.writeStateTo(worldStateArchive.getMutable()); final ProtocolContext<Void> protocolContext = new ProtocolContext<>(blockchain, worldStateArchive, null);