|
7 | 7 | using Nethermind.Core.Crypto;
|
8 | 8 | using Nethermind.Core.Extensions;
|
9 | 9 | using Nethermind.Core.Resettables;
|
| 10 | +using Nethermind.Core.Test.Builders; |
10 | 11 | using Nethermind.Db;
|
11 | 12 | using Nethermind.Specs.Forks;
|
12 | 13 | using Nethermind.Logging;
|
@@ -409,16 +410,33 @@ public void Persistent_state_restores_independent_of_transient_state(int snapsho
|
409 | 410 | _values[snapshot + 1].Should().BeEquivalentTo(provider.Get(new StorageCell(ctx.Address1, 1)).ToArray());
|
410 | 411 | }
|
411 | 412 |
|
| 413 | + /// <summary> |
| 414 | + /// Reset will reset transient state |
| 415 | + /// </summary> |
| 416 | + [Test] |
| 417 | + public void Selfdestruct_clears_cache() |
| 418 | + { |
| 419 | + PreBlockCaches preBlockCaches = new PreBlockCaches(); |
| 420 | + Context ctx = new(preBlockCaches); |
| 421 | + WorldState provider = BuildStorageProvider(ctx); |
| 422 | + StorageCell storageCell = new StorageCell(TestItem.AddressA, 1); |
| 423 | + preBlockCaches.StorageCache[storageCell] = [1, 2, 3]; |
| 424 | + provider.Get(storageCell); |
| 425 | + provider.Commit(Paris.Instance); |
| 426 | + provider.ClearStorage(TestItem.AddressA); |
| 427 | + provider.Get(storageCell).ToArray().Should().BeEquivalentTo(StorageTree.EmptyBytes); |
| 428 | + } |
| 429 | + |
412 | 430 | private class Context
|
413 | 431 | {
|
414 | 432 | public WorldState StateProvider { get; }
|
415 | 433 |
|
416 | 434 | public readonly Address Address1 = new(Keccak.Compute("1"));
|
417 | 435 | public readonly Address Address2 = new(Keccak.Compute("2"));
|
418 | 436 |
|
419 |
| - public Context() |
| 437 | + public Context(PreBlockCaches preBlockCaches = null) |
420 | 438 | {
|
421 |
| - StateProvider = new WorldState(new TrieStore(new MemDb(), LimboLogs.Instance), Substitute.For<IDb>(), LogManager); |
| 439 | + StateProvider = new WorldState(new TrieStore(new MemDb(), LimboLogs.Instance), Substitute.For<IDb>(), LogManager, preBlockCaches); |
422 | 440 | StateProvider.CreateAccount(Address1, 0);
|
423 | 441 | StateProvider.CreateAccount(Address2, 0);
|
424 | 442 | StateProvider.Commit(Frontier.Instance);
|
|
0 commit comments