Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UT for PR#2215 #2220

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
70fe372
Update UT_DataCache.cs
chenzhitong Jan 12, 2021
f137320
Remove SerializableWrapper, Update UT_CloneCache
chenzhitong Jan 12, 2021
b28e797
update
chenzhitong Jan 12, 2021
50d4c65
NativeContract.Ledger.GetBlock() / NativeContract.Ledger.GetTransacti…
chenzhitong Jan 12, 2021
c0c0809
Remove GetTransactionHeight and GetBlockchainHeight
chenzhitong Jan 12, 2021
a885b6f
Some fixes
shargon Jan 12, 2021
eb3503e
More fixes
shargon Jan 12, 2021
5bbdb15
Some fixes
shargon Jan 12, 2021
53916fd
More fixes
shargon Jan 12, 2021
5a095ef
Some fixes
shargon Jan 12, 2021
14f3882
Remove internal
shargon Jan 12, 2021
decdd4f
Fix UT_SmartContractHelper
shargon Jan 12, 2021
60a51c4
Fix UT_PolicyContract
shargon Jan 12, 2021
ced82bc
Fix UT_TransactionState
shargon Jan 12, 2021
105713a
Fix data cache ut
shargon Jan 12, 2021
0e4471e
More fixes
shargon Jan 12, 2021
963ed82
format
erikzhang Jan 14, 2021
ee0caca
Revert changes on StorageItem
shargon Jan 14, 2021
6475d5c
Remove unnecessary change
erikzhang Jan 14, 2021
eff2e9d
Fix UT_TrimmedBlock
shargon Jan 14, 2021
14d3161
Merge remote-tracking branch 'chenzhitong/fix-ut/ledger-contract' int…
shargon Jan 14, 2021
aa4b22f
Merge branch 'native/ledger-contract' into fix-ut/ledger-contract
erikzhang Jan 14, 2021
c413723
Update NonfungibleToken.cs
chenzhitong Jan 14, 2021
26dd1e9
Fix one UT
shargon Jan 14, 2021
0b17410
Fix other UT
shargon Jan 14, 2021
ff985cc
Merge remote-tracking branch 'chenzhitong/fix-ut/ledger-contract' int…
shargon Jan 14, 2021
177995e
Fix last ut
shargon Jan 14, 2021
4fc7ac2
Fix Equals
erikzhang Jan 14, 2021
73cdfa0
Recover UT
shargon Jan 14, 2021
9b70655
Merge remote-tracking branch 'chenzhitong/fix-ut/ledger-contract' int…
shargon Jan 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/neo/SmartContract/Native/NonfungibleToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected bool Transfer(ApplicationEngine engine, UInt160 to, byte[] tokenId)
return false;
if (!from.Equals(to))
{
token = engine.Snapshot.Storages.GetAndChange(key_token).GetInteroperable<TokenState>();
token = engine.Snapshot.GetAndChange(key_token).GetInteroperable<TokenState>();
StorageKey key_from = CreateStorageKey(Prefix_Account).Add(from);
NFTAccountState account = engine.Snapshot.GetAndChange(key_from).GetInteroperable<NFTAccountState>();
account.Remove(tokenId);
Expand Down
35 changes: 18 additions & 17 deletions tests/neo.UnitTests/IO/Caching/UT_CloneCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Neo.UnitTests.IO.Caching
{
[TestClass]
public class UT_CloneCache
{
ClonedCache clonedCache;
MyDataCache<MyKey, MyValue> myDataCache;
MyDataCache myDataCache;

[TestInitialize]
public void Init()
{
myDataCache = new MyDataCache<MyKey, MyValue>();
myDataCache = new MyDataCache();
clonedCache = new ClonedCache(myDataCache);
}

Expand Down Expand Up @@ -62,12 +63,12 @@ public void TestFindInternal()

items = clonedCache.Find(new MyKey("key2").ToArray());
items.ElementAt(0).Key.Should().Be(new MyKey("key2"));
items.ElementAt(0).Value.Should().Be(new MyValue("value2"));
new MyValue("value2").Should().Be(items.ElementAt(0).Value);
items.Count().Should().Be(1);

items = clonedCache.Find(new MyKey("key3").ToArray());
items.ElementAt(0).Key.Should().Be(new MyKey("key3"));
items.ElementAt(0).Value.Should().Be(new MyValue("value3"));
new MyValue("value3").Should().Be(items.ElementAt(0).Value);
items.Count().Should().Be(1);

items = clonedCache.Find(new MyKey("key4").ToArray());
Expand All @@ -81,9 +82,9 @@ public void TestGetInternal()
myDataCache.Add(new MyKey("key2"), new MyValue("value2"));
myDataCache.InnerDict.Add(new MyKey("key3"), new MyValue("value3"));

clonedCache[new MyKey("key1")].Should().Be(new MyValue("value1"));
clonedCache[new MyKey("key2")].Should().Be(new MyValue("value2"));
clonedCache[new MyKey("key3")].Should().Be(new MyValue("value3"));
new MyValue("value1").Should().Be(clonedCache[new MyKey("key1")]);
new MyValue("value2").Should().Be(clonedCache[new MyKey("key2")]);
new MyValue("value3").Should().Be(clonedCache[new MyKey("key3")]);

Action action = () =>
{
Expand All @@ -99,9 +100,9 @@ public void TestTryGetInternal()
myDataCache.Add(new MyKey("key2"), new MyValue("value2"));
myDataCache.InnerDict.Add(new MyKey("key3"), new MyValue("value3"));

clonedCache.TryGet(new MyKey("key1")).Should().Be(new MyValue("value1"));
clonedCache.TryGet(new MyKey("key2")).Should().Be(new MyValue("value2"));
clonedCache.TryGet(new MyKey("key3")).Should().Be(new MyValue("value3"));
new MyValue("value1").Should().Be(clonedCache.TryGet(new MyKey("key1")));
new MyValue("value2").Should().Be(clonedCache.TryGet(new MyKey("key2")));
new MyValue("value3").Should().Be(clonedCache.TryGet(new MyKey("key3")));
clonedCache.TryGet(new MyKey("key4")).Should().BeNull();
}

Expand All @@ -112,16 +113,16 @@ public void TestUpdateInternal()
myDataCache.Add(new MyKey("key2"), new MyValue("value2"));
myDataCache.InnerDict.Add(new MyKey("key3"), new MyValue("value3"));

clonedCache.GetAndChange(new MyKey("key1")).Value = "value_new_1";
clonedCache.GetAndChange(new MyKey("key2")).Value = "value_new_2";
clonedCache.GetAndChange(new MyKey("key3")).Value = "value_new_3";
clonedCache.GetAndChange(new MyKey("key1")).Value = Encoding.Default.GetBytes("value_new_1");
clonedCache.GetAndChange(new MyKey("key2")).Value = Encoding.Default.GetBytes("value_new_2");
clonedCache.GetAndChange(new MyKey("key3")).Value = Encoding.Default.GetBytes("value_new_3");

clonedCache.Commit();

clonedCache[new MyKey("key1")].Should().Be(new MyValue("value_new_1"));
clonedCache[new MyKey("key2")].Should().Be(new MyValue("value_new_2"));
clonedCache[new MyKey("key3")].Should().Be(new MyValue("value_new_3"));
myDataCache[new MyKey("key2")].Should().Be(new MyValue("value_new_2"));
new MyValue("value_new_1").Should().Be(clonedCache[new MyKey("key1")]);
new MyValue("value_new_2").Should().Be(clonedCache[new MyKey("key2")]);
new MyValue("value_new_3").Should().Be(clonedCache[new MyKey("key3")]);
new MyValue("value_new_2").Should().Be(clonedCache[new MyKey("key2")]);
}
}
}
Loading