public void Reset() { StateProvider.Reset(); StorageProvider.Reset(); _codeDb.ClearTempChanges(); }
private static void InitializeTestState(GeneralStateTest test, StateProvider stateProvider, IStorageProvider storageProvider, ISpecProvider specProvider) { foreach (KeyValuePair <Address, AccountState> accountState in test.Pre) { foreach (KeyValuePair <UInt256, byte[]> storageItem in accountState.Value.Storage) { storageProvider.Set(new StorageCell(accountState.Key, storageItem.Key), storageItem.Value.WithoutLeadingZeros().ToArray()); } stateProvider.CreateAccount(accountState.Key, accountState.Value.Balance); Keccak codeHash = stateProvider.UpdateCode(accountState.Value.Code); stateProvider.UpdateCodeHash(accountState.Key, codeHash, specProvider.GenesisSpec); stateProvider.SetNonce(accountState.Key, accountState.Value.Nonce); } storageProvider.Commit(); stateProvider.Commit(specProvider.GenesisSpec); storageProvider.CommitTrees(0); stateProvider.CommitTree(0); storageProvider.Reset(); stateProvider.Reset(); }
public void Does_not_require_recalculation_after_reset() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(TestItem.AddressA, 5); Action action = () => { var x = provider.StateRoot; }; action.Should().Throw <InvalidOperationException>(); provider.Reset(); action.Should().NotThrow <InvalidOperationException>(); }
public void Does_not_require_recalculation_after_reset() { StateProvider provider = new StateProvider(new TrieStore(new MemDb(), Logger), _codeDb, Logger); provider.CreateAccount(TestItem.AddressA, 5); Action action = () => { _ = provider.StateRoot; }; action.Should().Throw <InvalidOperationException>(); provider.Reset(); action.Should().NotThrow <InvalidOperationException>(); }
public void Touch_empty_trace_does_not_throw() { ParityLikeTxTracer tracer = new ParityLikeTxTracer(Build.A.Block.TestObject, null, ParityTraceTypes.StateDiff); StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); provider.CreateAccount(_address1, 0); Account account = provider.GetAccount(_address1); Assert.True(account.IsEmpty); provider.Commit(Frontier.Instance); // commit empty account (before the empty account fix in Spurious Dragon) Assert.True(provider.AccountExists(_address1)); provider.Reset(); // clear all caches provider.GetBalance(_address1); // justcache provider.AddToBalance(_address1, 0, SpuriousDragon.Instance); // touch Assert.DoesNotThrow(() => provider.Commit(SpuriousDragon.Instance, tracer)); }
public void ExecuteCode() { _virtualMachine.Run(_evmState, _txTracer); _stateProvider.Reset(); _storageProvider.Reset(); }
public void Reset() { StateProvider.Reset(); StorageProvider.Reset(); }