Skip to content

Commit

Permalink
Speed up travis (#1136)
Browse files Browse the repository at this point in the history
* Speed up

* Update UT_NEP6Wallet.cs

* Speed ut

* More speed up

* Format

* Remove blank line

* Reduce travis verbosity

* Coverage only on linux

* CollectCoverage only if is needed

* Update .travis.yml

* Already build

* no-restore

* Update .travis.yml

* Back verbosity

* Update netcore version

* Remove BOM

* Update nugets

* Fix fluent update

* Paralellize

* format

* Update .travis.yml

* Fix

* Update .travis.yml

* Min verbose

* Remove parallel execution

* Fix change

* Revert AsParallel()
  • Loading branch information
shargon committed Oct 3, 2019
1 parent c4023a4 commit 982e690
Show file tree
Hide file tree
Showing 36 changed files with 243 additions and 274 deletions.
20 changes: 13 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dist: bionic
osx_image: xcode9.1

mono: none
dotnet: 2.2.300
dotnet: 2.2.402

env:
- TEST_SUITE="without-cultures"
Expand All @@ -25,15 +25,21 @@ before_script:
- dotnet format --check --dry-run -w . -v diagnostic # check C# formatting for neo.sln
- cd neo.UnitTests
script: |
dotnet restore
if [[ "$TEST_SUITE" == cultures ]]; then
dotnet test
if [[ "$TEST_SUITE" == "cultures" ]]; then
dotnet test -v m --filter FullyQualifiedName=Neo.UnitTests.UT_Culture.All_Tests_Cultures
else
find * -name *.csproj | xargs -I % dotnet add % package coverlet.msbuild
dotnet test -v n --filter FullyQualifiedName!=Neo.UnitTests.UT_Culture.All_Tests_Cultures /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
if [[ "$TEST_SUITE" == "without-cultures" && "$TRAVIS_OS_NAME" == "linux" ]]; then
# Test & Calculate coverage
find * -name *.csproj | xargs -I % dotnet add % package coverlet.msbuild
dotnet test -v m --filter FullyQualifiedName!=Neo.UnitTests.UT_Culture.All_Tests_Cultures /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
else
# Only test
dotnet test -v m --filter FullyQualifiedName!=Neo.UnitTests.UT_Culture.All_Tests_Cultures
fi
fi
after_success: |
if [[ "$TEST_SUITE" == "without-cultures" ]]; then
if [[ "$TEST_SUITE" == "without-cultures" && "$TRAVIS_OS_NAME" == "linux" ]]; then
# Send coverage
echo "Test Success - Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)"
bash <(curl -s https://codecov.io/bash) -v
fi
Expand Down
34 changes: 17 additions & 17 deletions neo.UnitTests/Consensus/UT_Consensus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,17 @@ public void TestSerializeAndDeserializeConsensusContext()
copiedContext.Block.PrevHash.Should().Be(consensusContext.Block.PrevHash);
copiedContext.Block.Index.Should().Be(consensusContext.Block.Index);
copiedContext.ViewNumber.Should().Be(consensusContext.ViewNumber);
copiedContext.Validators.ShouldAllBeEquivalentTo(consensusContext.Validators);
copiedContext.Validators.Should().BeEquivalentTo(consensusContext.Validators);
copiedContext.MyIndex.Should().Be(consensusContext.MyIndex);
copiedContext.Block.ConsensusData.PrimaryIndex.Should().Be(consensusContext.Block.ConsensusData.PrimaryIndex);
copiedContext.Block.Timestamp.Should().Be(consensusContext.Block.Timestamp);
copiedContext.Block.NextConsensus.Should().Be(consensusContext.Block.NextConsensus);
copiedContext.TransactionHashes.ShouldAllBeEquivalentTo(consensusContext.TransactionHashes);
copiedContext.Transactions.ShouldAllBeEquivalentTo(consensusContext.Transactions);
copiedContext.Transactions.Values.ShouldAllBeEquivalentTo(consensusContext.Transactions.Values);
copiedContext.PreparationPayloads.ShouldAllBeEquivalentTo(consensusContext.PreparationPayloads);
copiedContext.CommitPayloads.ShouldAllBeEquivalentTo(consensusContext.CommitPayloads);
copiedContext.ChangeViewPayloads.ShouldAllBeEquivalentTo(consensusContext.ChangeViewPayloads);
copiedContext.TransactionHashes.Should().BeEquivalentTo(consensusContext.TransactionHashes);
copiedContext.Transactions.Should().BeEquivalentTo(consensusContext.Transactions);
copiedContext.Transactions.Values.Should().BeEquivalentTo(consensusContext.Transactions.Values);
copiedContext.PreparationPayloads.Should().BeEquivalentTo(consensusContext.PreparationPayloads);
copiedContext.CommitPayloads.Should().BeEquivalentTo(consensusContext.CommitPayloads);
copiedContext.ChangeViewPayloads.Should().BeEquivalentTo(consensusContext.ChangeViewPayloads);
}

[TestMethod]
Expand Down Expand Up @@ -315,9 +315,9 @@ public void TestSerializeAndDeserializeRecoveryMessageWithChangeViewsAndNoPrepar

var copiedMsg = TestUtils.CopyMsgBySerialization(msg, new RecoveryMessage()); ;

copiedMsg.ChangeViewMessages.ShouldAllBeEquivalentTo(msg.ChangeViewMessages);
copiedMsg.ChangeViewMessages.Should().BeEquivalentTo(msg.ChangeViewMessages);
copiedMsg.PreparationHash.Should().Be(msg.PreparationHash);
copiedMsg.PreparationMessages.ShouldAllBeEquivalentTo(msg.PreparationMessages);
copiedMsg.PreparationMessages.Should().BeEquivalentTo(msg.PreparationMessages);
copiedMsg.CommitMessages.Count.Should().Be(0);
}

Expand Down Expand Up @@ -409,10 +409,10 @@ public void TestSerializeAndDeserializeRecoveryMessageWithChangeViewsAndPrepareR

var copiedMsg = TestUtils.CopyMsgBySerialization(msg, new RecoveryMessage()); ;

copiedMsg.ChangeViewMessages.ShouldAllBeEquivalentTo(msg.ChangeViewMessages);
copiedMsg.PrepareRequestMessage.ShouldBeEquivalentTo(msg.PrepareRequestMessage);
copiedMsg.ChangeViewMessages.Should().BeEquivalentTo(msg.ChangeViewMessages);
copiedMsg.PrepareRequestMessage.Should().BeEquivalentTo(msg.PrepareRequestMessage);
copiedMsg.PreparationHash.Should().Be(null);
copiedMsg.PreparationMessages.ShouldAllBeEquivalentTo(msg.PreparationMessages);
copiedMsg.PreparationMessages.Should().BeEquivalentTo(msg.PreparationMessages);
copiedMsg.CommitMessages.Count.Should().Be(0);
}

Expand Down Expand Up @@ -470,9 +470,9 @@ public void TestSerializeAndDeserializeRecoveryMessageWithoutChangeViewsWithoutC
var copiedMsg = TestUtils.CopyMsgBySerialization(msg, new RecoveryMessage()); ;

copiedMsg.ChangeViewMessages.Count.Should().Be(0);
copiedMsg.PrepareRequestMessage.ShouldBeEquivalentTo(msg.PrepareRequestMessage);
copiedMsg.PrepareRequestMessage.Should().BeEquivalentTo(msg.PrepareRequestMessage);
copiedMsg.PreparationHash.Should().Be(null);
copiedMsg.PreparationMessages.ShouldAllBeEquivalentTo(msg.PreparationMessages);
copiedMsg.PreparationMessages.Should().BeEquivalentTo(msg.PreparationMessages);
copiedMsg.CommitMessages.Count.Should().Be(0);
}

Expand Down Expand Up @@ -550,10 +550,10 @@ public void TestSerializeAndDeserializeRecoveryMessageWithoutChangeViewsWithComm
var copiedMsg = TestUtils.CopyMsgBySerialization(msg, new RecoveryMessage()); ;

copiedMsg.ChangeViewMessages.Count.Should().Be(0);
copiedMsg.PrepareRequestMessage.ShouldBeEquivalentTo(msg.PrepareRequestMessage);
copiedMsg.PrepareRequestMessage.Should().BeEquivalentTo(msg.PrepareRequestMessage);
copiedMsg.PreparationHash.Should().Be(null);
copiedMsg.PreparationMessages.ShouldAllBeEquivalentTo(msg.PreparationMessages);
copiedMsg.CommitMessages.ShouldAllBeEquivalentTo(msg.CommitMessages);
copiedMsg.PreparationMessages.Should().BeEquivalentTo(msg.PreparationMessages);
copiedMsg.CommitMessages.Should().BeEquivalentTo(msg.CommitMessages);
}

private static ConsensusPayload MakeSignedPayload(ConsensusContext context, ConsensusMessage message, ushort validatorIndex, byte[] witnessInvocationScript)
Expand Down
8 changes: 4 additions & 4 deletions neo.UnitTests/Cryptography/ECC/UT_ECDsa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ public void TestSetup()
public void TestECDsaConstructor()
{
Action action = () => new ECDsa(key.PublicKey);
action.ShouldNotThrow();
action.Should().NotThrow();
action = () => new ECDsa(key.PrivateKey, key.PublicKey.Curve);
action.ShouldNotThrow();
action.Should().NotThrow();
}

[TestMethod]
public void TestGenerateSignature()
{
ECDsa sa = new ECDsa(key.PrivateKey, key.PublicKey.Curve);
byte[] message = System.Text.Encoding.Default.GetBytes("HelloWorld");
for (int i = 0; i < 30; i++)
for (int i = 0; i < 10; i++)
{
BigInteger[] result = sa.GenerateSignature(message);
result.Length.Should().Be(2);
}
sa = new ECDsa(key.PublicKey);
Action action = () => sa.GenerateSignature(message);
action.ShouldThrow<InvalidOperationException>();
action.Should().Throw<InvalidOperationException>();
}

[TestMethod]
Expand Down
4 changes: 2 additions & 2 deletions neo.UnitTests/Cryptography/ECC/UT_ECFieldElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public void TestECFieldElementConstructor()
{
BigInteger input = new BigInteger(100);
Action action = () => new ECFieldElement(input, ECCurve.Secp256k1);
action.ShouldNotThrow();
action.Should().NotThrow();

input = ECCurve.Secp256k1.Q;
action = () => new ECFieldElement(input, ECCurve.Secp256k1);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();
}

[TestMethod]
Expand Down
24 changes: 12 additions & 12 deletions neo.UnitTests/Cryptography/ECC/UT_ECPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,53 +57,53 @@ public void TestECPointConstructor()
point.Y.Should().Be(Y);
point.Curve.Should().Be(ECCurve.Secp256k1);
Action action = () => new ECPoint(X, null, ECCurve.Secp256k1);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();
action = () => new ECPoint(null, Y, ECCurve.Secp256k1);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();
}

[TestMethod]
public void TestDecodePoint()
{
byte[] input1 = { 0 };
Action action = () => ECPoint.DecodePoint(input1, ECCurve.Secp256k1);
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();

byte[] input2 = { 4, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, 152, 72,
58, 218, 119, 38, 163, 196, 101, 93, 164, 251, 252, 14, 17, 8, 168, 253, 23, 180, 72, 166, 133, 84, 25, 156, 71, 208, 143, 251, 16, 212, 184 };
ECPoint.DecodePoint(input2, ECCurve.Secp256k1).Should().Be(ECCurve.Secp256k1.G);
action = () => ECPoint.DecodePoint(input2.Take(32).ToArray(), ECCurve.Secp256k1);
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();

byte[] input3 = { 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, 152 };
byte[] input4 = { 3, 107, 23, 209, 242, 225, 44, 66, 71, 248, 188, 230, 229, 99, 164, 64, 242, 119, 3, 125, 129, 45, 235, 51, 160, 244, 161, 57, 69, 216, 152, 194, 150 };
ECPoint.DecodePoint(input3, ECCurve.Secp256k1).Should().Be(ECCurve.Secp256k1.G);
ECPoint.DecodePoint(input4, ECCurve.Secp256r1).Should().Be(ECCurve.Secp256r1.G);

action = () => ECPoint.DecodePoint(input3.Take(input3.Length - 1).ToArray(), ECCurve.Secp256k1);
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();
}

[TestMethod]
public void TestDeserializeFrom()
{
byte[] input1 = { 0 };
Action action = () => ECPoint.DeserializeFrom(new BinaryReader(new MemoryStream(input1)), ECCurve.Secp256k1);
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();

byte[] input2 = { 4, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, 152, 72,
58, 218, 119, 38, 163, 196, 101, 93, 164, 251, 252, 14, 17, 8, 168, 253, 23, 180, 72, 166, 133, 84, 25, 156, 71, 208, 143, 251, 16, 212, 184 };
ECPoint.DeserializeFrom(new BinaryReader(new MemoryStream(input2)), ECCurve.Secp256k1).Should().Be(ECCurve.Secp256k1.G);
action = () => ECPoint.DeserializeFrom(new BinaryReader(new MemoryStream(input2.Take(32).ToArray())), ECCurve.Secp256k1).Should().Be(ECCurve.Secp256k1.G);
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();

byte[] input3 = { 2, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, 152 };
ECPoint.DeserializeFrom(new BinaryReader(new MemoryStream(input3)), ECCurve.Secp256k1).Should().Be(ECCurve.Secp256k1.G);
byte[] input4 = { 3, 107, 23, 209, 242, 225, 44, 66, 71, 248, 188, 230, 229, 99, 164, 64, 242, 119, 3, 125, 129, 45, 235, 51, 160, 244, 161, 57, 69, 216, 152, 194, 150 };
ECPoint.DeserializeFrom(new BinaryReader(new MemoryStream(input4)), ECCurve.Secp256r1).Should().Be(ECCurve.Secp256r1.G);

action = () => ECPoint.DeserializeFrom(new BinaryReader(new MemoryStream(input3.Take(input3.Length - 1).ToArray())), ECCurve.Secp256k1).Should().Be(ECCurve.Secp256k1.G);
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();
}

[TestMethod]
Expand Down Expand Up @@ -178,7 +178,7 @@ public void TestFromBytes()
{
byte[] input1 = { 0 };
Action action = () => ECPoint.FromBytes(input1, ECCurve.Secp256k1);
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();

byte[] input2 = { 4, 121, 190, 102, 126, 249, 220, 187, 172, 85, 160, 98, 149, 206, 135, 11, 7, 2, 155, 252, 219, 45, 206, 40, 217, 89, 242, 129, 91, 22, 248, 23, 152, 72,
58, 218, 119, 38, 163, 196, 101, 93, 164, 251, 252, 14, 17, 8, 168, 253, 23, 180, 72, 166, 133, 84, 25, 156, 71, 208, 143, 251, 16, 212, 184 };
Expand Down Expand Up @@ -293,14 +293,14 @@ public void TestOpMultiply()
ECPoint p = null;
byte[] n = new byte[] { 1 };
Action action = () => p = p * n;
action.ShouldThrow<ArgumentNullException>();
action.Should().Throw<ArgumentNullException>();

p = ECCurve.Secp256k1.G;
n = null;
action.ShouldThrow<ArgumentNullException>();
action.Should().Throw<ArgumentNullException>();

n = new byte[] { 1 };
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();

p = ECCurve.Secp256k1.Infinity;
n = new byte[32];
Expand Down
2 changes: 1 addition & 1 deletion neo.UnitTests/Cryptography/UT_Base58.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void TestDecode()
Base58.Decode(encoded1).Should().BeEquivalentTo(decoded1);
Base58.Decode(encoded2).Should().BeEquivalentTo(decoded2);
Action action = () => Base58.Decode(encoded1 + "l").Should().BeEquivalentTo(decoded1);
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();
}
}
}
4 changes: 2 additions & 2 deletions neo.UnitTests/Cryptography/UT_BloomFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public void TestBloomFIlterConstructorGetKMTweak()
int m = -7, n = 10;
uint nTweak = 123456;
Action action = () => new BloomFilter(m, n, nTweak);
action.ShouldThrow<ArgumentOutOfRangeException>();
action.Should().Throw<ArgumentOutOfRangeException>();

m = 7;
n = -10;
action = () => new BloomFilter(m, n, nTweak);
action.ShouldThrow<ArgumentOutOfRangeException>();
action.Should().Throw<ArgumentOutOfRangeException>();

n = 10;
BloomFilter filter = new BloomFilter(m, n, nTweak);
Expand Down
2 changes: 1 addition & 1 deletion neo.UnitTests/Cryptography/UT_Crypto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void TestVerifySignature()

wrongKey = new byte[36];
Action action = () => Crypto.Default.VerifySignature(message, signature, wrongKey).Should().BeFalse();
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();
}
}
}
30 changes: 15 additions & 15 deletions neo.UnitTests/Cryptography/UT_Cryptography_Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@ public void TestAesEncrypt()

byte[] nullData = null;
Action action = () => nullData.AesEncrypt(key, iv);
action.ShouldThrow<ArgumentNullException>();
action.Should().Throw<ArgumentNullException>();

byte[] nullKey = null;
action = () => data.AesEncrypt(nullKey, iv);
action.ShouldThrow<ArgumentNullException>();
action.Should().Throw<ArgumentNullException>();

byte[] nullIv = null;
action = () => data.AesEncrypt(key, nullIv);
action.ShouldThrow<ArgumentNullException>();
action.Should().Throw<ArgumentNullException>();

byte[] wrongData = Encoding.ASCII.GetBytes("000000000000000000000000000000001"); ;
action = () => wrongData.AesEncrypt(key, iv);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();

byte[] wrongKey = Encoding.ASCII.GetBytes("123456781234567812345678123456780"); ;
action = () => data.AesEncrypt(wrongKey, iv);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();

byte[] wrongIv = Encoding.ASCII.GetBytes("12345678123456780"); ;
action = () => data.AesEncrypt(key, wrongIv);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();
}

[TestMethod]
Expand All @@ -83,27 +83,27 @@ public void TestAesDecrypt()

byte[] nullData = null;
Action action = () => nullData.AesDecrypt(key, iv);
action.ShouldThrow<ArgumentNullException>();
action.Should().Throw<ArgumentNullException>();

byte[] nullKey = null;
action = () => data.AesDecrypt(nullKey, iv);
action.ShouldThrow<ArgumentNullException>();
action.Should().Throw<ArgumentNullException>();

byte[] nullIv = null;
action = () => data.AesDecrypt(key, nullIv);
action.ShouldThrow<ArgumentNullException>();
action.Should().Throw<ArgumentNullException>();

byte[] wrongData = Encoding.ASCII.GetBytes("00000000000000001"); ;
action = () => wrongData.AesDecrypt(key, iv);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();

byte[] wrongKey = Encoding.ASCII.GetBytes("123456781234567812345678123456780"); ;
action = () => data.AesDecrypt(wrongKey, iv);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();

byte[] wrongIv = Encoding.ASCII.GetBytes("12345678123456780"); ;
action = () => data.AesDecrypt(key, wrongIv);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();
}

[TestMethod]
Expand All @@ -116,11 +116,11 @@ public void TestBase58CheckDecode()

input = "3v";
Action action = () => input.Base58CheckDecode();
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();

input = "3vQB7B6MrGQZaxCuFg4og";
action = () => input.Base58CheckDecode();
action.ShouldThrow<FormatException>();
action.Should().Throw<FormatException>();
}

[TestMethod]
Expand Down Expand Up @@ -215,7 +215,7 @@ public void TestToArray()

SecureString nullString = null;
Action action = () => nullString.ToArray();
action.ShouldThrow<NullReferenceException>();
action.Should().Throw<NullReferenceException>();

var zeroString = new SecureString();
var result = zeroString.ToArray();
Expand Down
2 changes: 1 addition & 1 deletion neo.UnitTests/Cryptography/UT_MerkleTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void TestBuildAndDepthFirstSearch()
{
IReadOnlyList<UInt256> hashNull = new UInt256[] { };
Action action = () => new MerkleTree(hashNull);
action.ShouldThrow<ArgumentException>();
action.Should().Throw<ArgumentException>();

byte[] array1 = { 0x01 };
var hash1 = GetByteArrayHash(array1);
Expand Down
Loading

0 comments on commit 982e690

Please sign in to comment.