forked from neo-project/neo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Recreate unit tests on new branch, after source repo rebranding and renaming, faster than fixing a load of merge conflicts * finish testing CalculateNetFee in block.cs. Add some dummy classes to help test. Normalise the namespaces and remove unnecessary usings. * improve the culture testing of AssetState.cs GetName * Add a general unit test that will run all other unit tests, in a variety of cultures * Deserialize and Serialize unit tests for block.cs * fix tests so that daylight savings dont affect expected result * Block.cs tests for Equals() and Trim() and FromTrimmedData() * Update README with NEO and correct folder * test for RebuildMerkleRoot() * tests for tojson() and verify() when completely is false * test for block verify fail when consensus doesn't match * fix failing test from merge conflicts
- Loading branch information
Showing
8 changed files
with
723 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
using Neo.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using Neo.Cryptography.ECC; | ||
|
||
namespace Neo.UnitTests | ||
{ | ||
public class TestBlockchain : Blockchain | ||
{ | ||
private UInt256 _assetId; | ||
|
||
public TestBlockchain(UInt256 assetId) | ||
{ | ||
_assetId = assetId; | ||
} | ||
|
||
public override UInt256 CurrentBlockHash => throw new NotImplementedException(); | ||
|
||
public override UInt256 CurrentHeaderHash => throw new NotImplementedException(); | ||
|
||
public override uint HeaderHeight => throw new NotImplementedException(); | ||
|
||
public override uint Height => throw new NotImplementedException(); | ||
|
||
public override bool AddBlock(Block block) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override bool ContainsBlock(UInt256 hash) | ||
{ | ||
return true; // for verify in UT_Block | ||
} | ||
|
||
public override bool ContainsTransaction(UInt256 hash) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override bool ContainsUnspent(UInt256 hash, ushort index) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override void Dispose() | ||
{ | ||
// do nothing | ||
} | ||
|
||
public override AccountState GetAccountState(UInt160 script_hash) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override AssetState GetAssetState(UInt256 asset_id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override Block GetBlock(UInt256 hash) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override UInt256 GetBlockHash(uint height) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override ContractState GetContract(UInt160 hash) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override IEnumerable<ValidatorState> GetEnrollments() | ||
{ | ||
ECPoint ecp = TestUtils.StandbyValidators[0]; | ||
return new ValidatorState[] { new ValidatorState() { PublicKey = ecp } }; | ||
} | ||
|
||
public override Header GetHeader(uint height) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override Header GetHeader(UInt256 hash) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override Block GetNextBlock(UInt256 hash) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override UInt256 GetNextBlockHash(UInt256 hash) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override StorageItem GetStorageItem(StorageKey key) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override long GetSysFeeAmount(UInt256 hash) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override Transaction GetTransaction(UInt256 hash, out int height) | ||
{ | ||
height = 0; | ||
return new TestTransaction(_assetId, TransactionType.ClaimTransaction); | ||
} | ||
|
||
public override Dictionary<ushort, SpentCoin> GetUnclaimed(UInt256 hash) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override TransactionOutput GetUnspent(UInt256 hash, ushort index) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override IEnumerable<VoteState> GetVotes(IEnumerable<Transaction> others) | ||
{ | ||
VoteState vs = new VoteState() { Count = Fixed8.FromDecimal(1), PublicKeys = TestUtils.StandbyValidators}; | ||
return new VoteState[] | ||
{ | ||
vs | ||
}; | ||
} | ||
|
||
public override bool IsDoubleSpend(Transaction tx) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override void AddHeaders(IEnumerable<Header> headers) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Neo.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Neo.UnitTests | ||
{ | ||
public class TestTransaction : Transaction | ||
{ | ||
public TestTransaction(UInt256 assetId, TransactionType type) : base(type) | ||
{ | ||
TransactionOutput transVal = new TransactionOutput(); | ||
transVal.Value = Fixed8.FromDecimal(50); | ||
transVal.AssetId = assetId; | ||
base.Outputs = new TransactionOutput[1] { transVal }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
using System.IO; | ||
using System.Text; | ||
using Neo.Core; | ||
using Neo.UnitTest; | ||
|
||
namespace Neo.UnitTests | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.