Exemple #1
0
        public void Non_existing()
        {
            StorageCell  storageCell = new StorageCell(_address1, UInt256.One);
            IReleaseSpec spec        = MuirGlacier.Instance;

            MemDb           stateDb         = new MemDb();
            TrieStore       trieStore       = new TrieStore(stateDb, Logger);
            StateProvider   provider        = new StateProvider(trieStore, new MemDb(), Logger);
            StorageProvider storageProvider = new StorageProvider(trieStore, provider, Logger);

            void CommitEverything()
            {
                storageProvider.Commit();
                storageProvider.CommitTrees(0);
                provider.Commit(spec);
                provider.CommitTree(0);
            }

            provider.CreateAccount(_address1, 1);
            storageProvider.Set(storageCell, new byte[] { 1 });
            CommitEverything();
            Keccak stateRoot0 = provider.StateRoot;

            StateReader reader =
                new StateReader(new TrieStore(stateDb, LimboLogs.Instance), Substitute.For <IDb>(), Logger);
            Keccak storageRoot = reader.GetStorageRoot(stateRoot0, _address1);

            reader.GetStorage(storageRoot, storageCell.Index + 1).Should().BeEquivalentTo(new byte[] { 0 });
            reader.GetStorage(Keccak.EmptyTreeHash, storageCell.Index + 1).Should().BeEquivalentTo(new byte[] { 0 });
        }
Exemple #2
0
 private Task StartStorageTask(StateReader reader, Keccak stateRoot, StorageCell storageCell, byte[] value)
 {
     return(Task.Run(
                () =>
     {
         for (int i = 0; i < 1000; i++)
         {
             Keccak storageRoot = reader.GetStorageRoot(stateRoot, storageCell.Address);
             byte[] result = reader.GetStorage(storageRoot, storageCell.Index);
             result.Should().BeEquivalentTo(value);
         }
     }));
 }