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

Add and update some Unit tests in IO module #998

Merged
merged 187 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
53e0ccf
testDemo
Jul 6, 2019
877ff70
Merge remote-tracking branch 'upstream/master'
eryeer Jul 8, 2019
ad5e1a9
add dll lib
eryeer Jul 8, 2019
9d70536
add dbsnapshot dispose
eryeer Jul 8, 2019
a61cac3
Merge remote-tracking branch 'upstream/master'
eryeer Jul 9, 2019
71675aa
test get blocks in levelDBStore
eryeer Jul 9, 2019
c55415b
add levelDBStore test funcs
eryeer Jul 9, 2019
d3e55d8
fix levelDBStore funcs
eryeer Jul 9, 2019
e440d60
add DbCache addInternal
eryeer Jul 9, 2019
7598dfa
differ db path
Jul 9, 2019
2ea1f86
space
Jul 9, 2019
ada729a
Merge t push
eryeer Jul 10, 2019
e581d8a
fix delete internal test
eryeer Jul 10, 2019
53e155f
add test getInternal tryGetInternal move libleveldb.dll
eryeer Jul 10, 2019
9deaa7d
Merge pull request #1 from eryeer/fix/db-path
eryeer Jul 10, 2019
7c6b9a1
add dbCache method test
eryeer Jul 10, 2019
0f50d07
Merge branch 'master' of github.com:eryeer/neoUT
eryeer Jul 10, 2019
86ed33f
add store test
eryeer Jul 10, 2019
cf4e202
add cache unit tests
Jul 10, 2019
1190766
add cache unit tests
Jul 10, 2019
ec9f488
Merge branch 'master' of github.com:eryeer/neoUT
Jul 10, 2019
235321f
up readonly max_capacity
Jul 10, 2019
c6df5ea
Merge remote-tracking branch 'upstream/master'
eryeer Jul 11, 2019
801165a
Merge branch 'master' of github.com:eryeer/neoUT
eryeer Jul 11, 2019
7fb81c4
fix leveldbexception
eryeer Jul 11, 2019
18b3562
fix comment on UT_Cache
eryeer Jul 11, 2019
bbf66fe
format
Jul 11, 2019
299401a
fix multithread test problem
eryeer Jul 11, 2019
f0214f8
up cache
Jul 11, 2019
c97b260
Merge branch 'master' of github.com:eryeer/neoUT
Jul 11, 2019
137672c
update travis config
eryeer Jul 11, 2019
48d2af9
update travis.yml
eryeer Jul 11, 2019
ad5cff3
test DbMetaDataCache
ZhangTao1596 Jul 11, 2019
e8878d4
fix db directory
ZhangTao1596 Jul 11, 2019
08fe898
Merge pull request #2 from eryeer/test/leveldb.dbmetadatecache
ZhangTao1596 Jul 11, 2019
a16d40b
format and update travis for maxos
eryeer Jul 11, 2019
de3f249
Merge branch 'master' of github.com:eryeer/neoUT
eryeer Jul 11, 2019
0ec6a4b
Merge branch 'master' into master
vncoelho Jul 11, 2019
041e800
Merge branch 'master' into master
vncoelho Jul 11, 2019
4d13f39
fix mac env travis
eryeer Jul 12, 2019
cceceef
2019/7/12 10:34
lmy0930 Jul 12, 2019
888df61
Merge branch 'master' of https://github.com/eryeer/neoUT
lmy0930 Jul 12, 2019
3b5697d
2019/7/12 11:01
lmy0930 Jul 12, 2019
f379b9f
remove commented line
eryeer Jul 12, 2019
9ebc18c
test BigDecimal
Jul 12, 2019
205fc01
fix format and csproj
eryeer Jul 12, 2019
f9de384
Merge branch 'ut' of github.com:eryeer/neoUT into ut
eryeer Jul 12, 2019
0baf66b
Merge pull request #3 from eryeer/ut
eryeer Jul 12, 2019
984ddd9
rm coverage.opencover.xml
eryeer Jul 12, 2019
ea3d8be
update method name
eryeer Jul 12, 2019
4a3279c
Merge pull request #4 from eryeer/ut
eryeer Jul 12, 2019
115008e
add UT_P_Helper
Jul 12, 2019
9c23106
modify UT_P_Helper
Jul 12, 2019
583db9d
modify UT_P_helper
Jul 12, 2019
f30b58d
Clean ut
shargon Jul 12, 2019
d11b639
test Base58 & BloomFilter
Jul 12, 2019
4e014ab
Update UT_Cache.cs
shargon Jul 12, 2019
82e8754
Correct Typo
Jul 12, 2019
1d65676
test JsonArray
eryeer Jul 12, 2019
925496f
update namespace
eryeer Jul 12, 2019
f493318
Merge pull request #5 from shargon/clean-ut
eryeer Jul 12, 2019
091d655
update namespace
eryeer Jul 12, 2019
455d436
update format
eryeer Jul 12, 2019
4d53e58
update format
eryeer Jul 12, 2019
93c69f4
Merge branch 'ut' of github.com:eryeer/neoUT into ut
Jul 12, 2019
63aecea
Merge branch 'master' into master
eryeer Jul 14, 2019
9d37be7
Merge remote-tracking branch 'upstream/master' into ut
eryeer Jul 15, 2019
299093b
organise folder structure
eryeer Jul 15, 2019
007165e
add UT_JString
Jul 15, 2019
6aa995b
Merge branch 'ut' of github.com:eryeer/neoUT into ut
Jul 15, 2019
2aa85b6
test JBoolean JNumber & JObject
eryeer Jul 15, 2019
d7a8174
Merge branch 'ut' of github.com:eryeer/neoUT into ut
eryeer Jul 15, 2019
b8fb5bf
Merge remote-tracking branch 'upstream/master'
eryeer Jul 16, 2019
6c279a0
Merge remote-tracking branch 'upstream/master' into ut
eryeer Jul 16, 2019
57f740b
2019/7/16 10:30
lmy0930 Jul 16, 2019
d6dce91
Merge branch 'ut' of https://github.com/eryeer/neoUT into ut
lmy0930 Jul 16, 2019
a31d6ac
fix timestamp
eryeer Jul 16, 2019
609ba6f
test ECDsa and Crypto
Jul 16, 2019
571938e
test OrderedDictionary & complete IO.Json tests
eryeer Jul 16, 2019
5a5c3d7
Merge branch 'ut' of github.com:eryeer/neoUT into ut
eryeer Jul 16, 2019
1ca84d9
2019/7/16 17:33
lmy0930 Jul 16, 2019
e5c1783
Merge branch 'ut' of https://github.com/eryeer/neoUT into ut
lmy0930 Jul 16, 2019
c8402ac
test FIFOSet
eryeer Jul 16, 2019
00d2579
Merge branch 'ut' of github.com:eryeer/neoUT into ut
eryeer Jul 16, 2019
3369ca5
add CloneCache and DataCache unit tests
Jul 16, 2019
85404a6
Merge branch 'ut' of github.com:eryeer/neoUT into ut
Jul 16, 2019
97ec014
Merge remote-tracking branch 'upstream/master'
eryeer Jul 17, 2019
5570a5b
Merge remote-tracking branch 'upstream/master' into ut
eryeer Jul 17, 2019
d094af9
fix namespace
eryeer Jul 17, 2019
4b753ef
add UT_Cryptography_Helper
Jul 17, 2019
bd4ee5a
Merge branch 'ut' of github.com:eryeer/neoUT into ut
Jul 17, 2019
327b036
format UT_CloneCache and UT_DataCache
Jul 17, 2019
b693471
add UT_DataCache.GetAndChange unit test
Jul 17, 2019
6975292
Merge remote-tracking branch 'upstream/master'
eryeer Jul 18, 2019
2ca6662
Merge remote-tracking branch 'upstream/master' into ut
eryeer Jul 18, 2019
2fffcaf
update namespace
eryeer Jul 18, 2019
e220a28
remove comment code
Jul 18, 2019
c4d4acd
Merge remote-tracking branch 'upstream/master'
eryeer Jul 19, 2019
a071acb
Merge remote-tracking branch 'upstream/master' into ut
eryeer Jul 19, 2019
7ad2e6e
delete Persistence part
eryeer Jul 19, 2019
269085b
2019/7/19 11:07
lmy0930 Jul 19, 2019
88a7dd9
Merge branch 'ut' of https://github.com/eryeer/neoUT into ut
lmy0930 Jul 19, 2019
0b8f79a
Fix Base58 Test
Jul 19, 2019
8403ceb
Merge branch 'ut' of https://github.com/eryeer/neoUT into ut
lmy0930 Jul 19, 2019
a752eb4
2019/7/19 11:33
lmy0930 Jul 19, 2019
9bd5702
update IOHelper exception assert
eryeer Jul 19, 2019
b66712d
Merge branch 'ut' of github.com:eryeer/neoUT into ut
eryeer Jul 19, 2019
2b06d6c
2019/7/19 14:22
lmy0930 Jul 19, 2019
61ded58
format IOHelper
eryeer Jul 19, 2019
de75342
merge conflict of IOHelper
eryeer Jul 19, 2019
db06a47
review IO.Wrapper
eryeer Jul 19, 2019
336c3c3
review Wallets.SQLite UT
eryeer Jul 19, 2019
e4a6fa6
Test ECFieldElement ECPoint
Jul 19, 2019
4234650
Merge branch 'ut' of https://github.com/eryeer/neoUT into ut
Jul 19, 2019
935fec4
refactor package
Jul 19, 2019
c87fd50
format ECDsa
eryeer Jul 19, 2019
3d36710
merge conflict
eryeer Jul 19, 2019
599d077
update namespace
eryeer Jul 19, 2019
61dd25a
Code fix
Jul 19, 2019
87526bd
Merge branch 'ut' of https://github.com/eryeer/neoUT into ut
Jul 19, 2019
ae5129c
review cache
Jul 19, 2019
72254eb
modify UT_JString
Jul 19, 2019
aeb5869
fomat
eryeer Jul 19, 2019
fddce6a
merge confilct
eryeer Jul 19, 2019
6232806
format UT_ECPoint
Jul 19, 2019
5169605
resolve and format UT_Ecdsa
Jul 19, 2019
a48a0c3
using Actin replace with try-catch
Jul 19, 2019
cc2dcac
add UT_CloneMetaCache and UT_MetaDataCache
Jul 19, 2019
5856bc6
Merge remote-tracking branch 'upstream/master'
eryeer Jul 19, 2019
0eb76c8
merge
eryeer Jul 19, 2019
6c44ceb
update namespace
eryeer Jul 19, 2019
0343b21
Merge branch 'ut' of github.com:eryeer/neoUT into ut
eryeer Jul 19, 2019
714123d
format UT_DataCache.cs
Jul 21, 2019
2b4b1d3
Merge branch 'ut' of github.com:eryeer/neoUT into ut
Jul 21, 2019
3010a2c
Merge remote-tracking branch 'upstream/master'
eryeer Jul 22, 2019
ef36ac0
Merge remote-tracking branch 'upstream/master' into ut
eryeer Jul 22, 2019
86696a1
Code Fix
Jul 22, 2019
bf0672a
Merge branch 'ut' of https://github.com/eryeer/neoUT into ut
Jul 22, 2019
47f3afe
merge conflict
eryeer Jul 22, 2019
958f319
Merge branch 'ut' of github.com:eryeer/neoUT into ut
eryeer Jul 22, 2019
d454960
format
eryeer Jul 22, 2019
1551d6a
update csproj
eryeer Jul 22, 2019
2ff4dc8
Code fix for UT_ECFieldElement and UT_ECPoint
Jul 22, 2019
2763eeb
Merge branch 'ut' of https://github.com/eryeer/neoUT into ut
Jul 22, 2019
5d77ca9
Code fix
Jul 22, 2019
3f36346
Merge branch 'ut' of github.com:eryeer/neoUT into ut
eryeer Jul 22, 2019
bce3f94
format
eryeer Jul 22, 2019
4f87abc
update travis
eryeer Jul 22, 2019
7150321
delete deleteFiles
eryeer Jul 22, 2019
93ee3fa
Merge pull request #6 from eryeer/ut
eryeer Jul 22, 2019
2044b11
fix path and comment
eryeer Jul 22, 2019
d396d23
Merge remote-tracking branch 'upstream/master'
eryeer Jul 22, 2019
54679e4
update travis
eryeer Jul 22, 2019
dbb7b07
Merge remote-tracking branch 'upstream/master'
eryeer Jul 23, 2019
0581b4a
delete test ToTimeStamp
eryeer Jul 23, 2019
143ab3d
Merge branch 'master' into master
eryeer Jul 23, 2019
d382be8
format UT_*Cache
Jul 23, 2019
ced2ee6
Merge pull request #7 from eryeer/ut_io_cache
eryeer Jul 23, 2019
f8c8597
update format
eryeer Jul 23, 2019
d90a850
Merge branch 'master' of github.com:eryeer/neoUT
eryeer Jul 23, 2019
1808a54
fomat
eryeer Jul 23, 2019
0f362c2
use hex extensions in Cryptography_Helper
Jul 23, 2019
e2a199d
Merge branch 'master' into master
eryeer Jul 24, 2019
9970a0a
Merge pull request #8 from ShawnYun/master
eryeer Jul 24, 2019
124e8f0
remove reflection
eryeer Jul 24, 2019
6a517e7
optimization of UT_DataCache
eryeer Jul 24, 2019
b152a49
update namespace
eryeer Jul 24, 2019
547279d
modify TestSha256
eryeer Jul 24, 2019
630f942
Merge branch 'master' into master
eryeer Jul 25, 2019
29dc9c1
Merge remote-tracking branch 'upstream/master'
eryeer Jul 29, 2019
91896fb
update UT in crypto module
eryeer Jul 29, 2019
8fd545f
Rename UT_Scrypt.cs to UT_SCrypt.cs
eryeer Jul 29, 2019
1259556
format
eryeer Jul 29, 2019
2c16837
update UT_Murmur3
eryeer Jul 29, 2019
918cfdb
Merge branch 'master' into master
eryeer Jul 29, 2019
a4ac0ca
Merge remote-tracking branch 'upstream/master'
eryeer Jul 30, 2019
8b2da2e
Merge remote-tracking branch 'upstream/master'
eryeer Jul 31, 2019
78558ad
Merge remote-tracking branch 'upstream/master'
eryeer Aug 1, 2019
49d1b23
Merge remote-tracking branch 'upstream/master'
eryeer Aug 5, 2019
9edf9a6
update IO module test
eryeer Aug 5, 2019
4ed359e
delete empty line
eryeer Aug 5, 2019
78c16f7
changename
eryeer Aug 5, 2019
40f1f60
delete empty line
eryeer Aug 5, 2019
5e8aa8c
Merge remote-tracking branch 'upstream/master'
eryeer Aug 5, 2019
492eed0
revert commit
eryeer Aug 6, 2019
25e52e6
Merge remote-tracking branch 'upstream/master'
eryeer Aug 6, 2019
42ac8ec
Merge branch 'master' into master
eryeer Aug 7, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.IO.Caching;
using System;
using System.Collections;
using System.Linq;

namespace Neo.UnitTests.IO.Caching
Expand Down Expand Up @@ -81,12 +82,38 @@ public void TestAdd()
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x02
});
var set = new FIFOSet<UInt256>(1, 1);
set.Add(a);
set.Add(b);
var set = new FIFOSet<UInt256>(1, 1)
{
a,
b
};
CollectionAssert.AreEqual(set.ToArray(), new UInt256[] { b });
}

[TestMethod]
public void TestGetEnumerator()
{
var a = new UInt256(new byte[32] {
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01
});
var b = new UInt256(new byte[32] {
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x02
});
var set = new FIFOSet<UInt256>(1, 1)
{
a,
b
};
IEnumerable ie = set;
ie.GetEnumerator().Should().NotBeNull();
}

[TestMethod]
public void TestExceptWith()
{
Expand All @@ -109,10 +136,12 @@ public void TestExceptWith()
0x01, 0x03
});

var set = new FIFOSet<UInt256>(10);
set.Add(a);
set.Add(b);
set.Add(c);
var set = new FIFOSet<UInt256>(10)
{
a,
b,
c
};
set.ExceptWith(new UInt256[] { b, c });
CollectionAssert.AreEqual(set.ToArray(), new UInt256[] { a });
}
Expand Down
42 changes: 42 additions & 0 deletions neo.UnitTests/IO/Caching/UT_OrderedDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.IO.Caching;
using System.Collections;
using System.Collections.Generic;

namespace Neo.UnitTests.IO.Caching
{
Expand Down Expand Up @@ -83,5 +85,45 @@ public void TestTryGetValue()
od.TryGetValue("d", out uint j).Should().BeFalse();
j.Should().Be(0);
}

[TestMethod]
public void TestCollectionAddAndContains()
{
var pair = new KeyValuePair<string, uint>("d", 4);
ICollection<KeyValuePair<string, uint>> collection = od;
collection.Add(pair);
collection.Contains(pair).Should().BeTrue();
}

[TestMethod]
public void TestCollectionCopyTo()
{
var arr = new KeyValuePair<string, uint>[3];
ICollection<KeyValuePair<string, uint>> collection = od;
collection.CopyTo(arr, 0);
arr[0].Key.Should().Be("a");
arr[0].Value.Should().Be(1);
arr[1].Key.Should().Be("b");
arr[1].Value.Should().Be(2);
arr[2].Key.Should().Be("c");
arr[2].Value.Should().Be(3);
}

[TestMethod]
public void TestCollectionRemove()
{
ICollection<KeyValuePair<string, uint>> collection = od;
var pair = new KeyValuePair<string, uint>("a", 1);
collection.Remove(pair);
collection.Contains(pair).Should().BeFalse();
collection.Count.Should().Be(2);
}

[TestMethod]
public void TestGetEnumerator()
{
IEnumerable collection = od;
collection.GetEnumerator().MoveNext().Should().BeTrue();
}
}
}
80 changes: 80 additions & 0 deletions neo.UnitTests/IO/Caching/UT_ReflectionCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.IO.Caching;
using System;

namespace Neo.UnitTests.IO.Caching
{
public class TestItem { }

public class TestItem1 : TestItem { }

public class TestItem2 : TestItem { }

public enum MyTestEnum : byte
{
[ReflectionCache(typeof(TestItem1))]
Item1 = 0x00,

[ReflectionCache(typeof(TestItem2))]
Item2 = 0x01,
}

public enum MyEmptyEnum : byte { }

[TestClass]
public class UT_ReflectionCache
{
ReflectionCache<byte> reflectionCache;

[TestInitialize]
public void SetUp()
{
reflectionCache = ReflectionCache<byte>.CreateFromEnum<MyTestEnum>();
}

[TestMethod]
public void TestCreateFromEnum()
{
reflectionCache.Should().NotBeNull();
}

[TestMethod]
public void TestCreateFromObjectNotEnum()
{
Action action = () => ReflectionCache<byte>.CreateFromEnum<int>();
action.ShouldThrow<ArgumentException>();
}

[TestMethod]
public void TestCreateFromEmptyEnum()
{
reflectionCache = ReflectionCache<byte>.CreateFromEnum<MyEmptyEnum>();
reflectionCache.Count.Should().Be(0);
}

[TestMethod]
public void TestCreateInstance()
{
object item1 = reflectionCache.CreateInstance((byte)MyTestEnum.Item1, null);
(item1 is TestItem1).Should().BeTrue();

object item2 = reflectionCache.CreateInstance((byte)MyTestEnum.Item2, null);
(item2 is TestItem2).Should().BeTrue();

object item3 = reflectionCache.CreateInstance(0x02, null);
item3.Should().BeNull();
}

[TestMethod]
public void TestCreateInstance2()
{
TestItem defaultItem = new TestItem1();
object item2 = reflectionCache.CreateInstance((byte)MyTestEnum.Item2, defaultItem);
(item2 is TestItem2).Should().BeTrue();

object item1 = reflectionCache.CreateInstance(0x02, new TestItem1());
(item1 is TestItem1).Should().BeTrue();
}
}
}
41 changes: 41 additions & 0 deletions neo.UnitTests/IO/Caching/UT_RelayCache.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.IO.Caching;
using Neo.Network.P2P.Payloads;

namespace Neo.UnitTests.IO.Caching
{
[TestClass]
public class UT_RelayCache
{
RelayCache relayCache;

[TestInitialize]
public void SetUp()
{
relayCache = new RelayCache(10);
}

[TestMethod]
public void TestGetKeyForItem()
{
Transaction tx = new Transaction()
{
Version = 0,
Nonce = 1,
Sender = UInt160.Parse("0xa400ff00ff00ff00ff00ff00ff00ff00ff00ff01"),
SystemFee = 0,
NetworkFee = 0,
ValidUntilBlock = 100,
Attributes = new TransactionAttribute[0],
Script = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04 },
Witnesses = new Witness[0]
};
relayCache.Add(tx);

relayCache.Contains(tx).Should().BeTrue();
relayCache.TryGet(tx.Hash, out IInventory tmp).Should().BeTrue();
(tmp is Transaction).Should().BeTrue();
}
}
}
Loading