forked from neo-project/neo-devpack-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase block height in the TestEngine
- Loading branch information
Showing
12 changed files
with
324 additions
and
21 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
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
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,33 @@ | ||
using Neo.Wallets; | ||
|
||
namespace Neo.TestingEngine | ||
{ | ||
class TestAccount : WalletAccount | ||
{ | ||
public override bool HasKey => this.key != null; | ||
|
||
private byte[] privateKey; | ||
private UInt160 scriptHash; | ||
private KeyPair key = null; | ||
|
||
public TestAccount(UInt160 scriptHash, byte[] privKey = null) : base(scriptHash) | ||
{ | ||
if (privKey != null) | ||
{ | ||
this.privateKey = privKey; | ||
} | ||
else | ||
{ | ||
this.privateKey = new byte[32]; | ||
} | ||
|
||
this.scriptHash = scriptHash; | ||
this.key = new KeyPair(this.privateKey); | ||
} | ||
|
||
public override KeyPair GetKey() | ||
{ | ||
return this.key; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...act.Framework.UnitTests/TestBlockchain.cs → src/TestEngine/TestUtils/TestBlockchain.cs
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,40 @@ | ||
using Neo.Consensus; | ||
using Neo.Cryptography.ECC; | ||
using Neo.Network.P2P.Payloads; | ||
using Neo.Persistence; | ||
using Neo.SmartContract; | ||
using Neo.Wallets; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Neo.TestingEngine | ||
{ | ||
public class TestConsensusContext : ConsensusContext | ||
{ | ||
public TestConsensusContext(ECPoint[] validators, Wallet wallet, IStore store) : base(wallet, store) | ||
{ | ||
this.Validators = validators; | ||
this.CommitPayloads = new ConsensusPayload[validators.Length]; | ||
} | ||
|
||
public void SetBlock(Block block) | ||
{ | ||
this.Block = block; | ||
} | ||
|
||
public Block CreateBlock() | ||
{ | ||
EnsureHeader(); | ||
Contract contract = Contract.CreateMultiSigContract(M, Validators); | ||
ContractParametersContext sc = new ContractParametersContext(Block); | ||
|
||
var witness = new Witness(); | ||
witness.InvocationScript = contract.Script; | ||
witness.VerificationScript = new byte[0]; | ||
Block.Witness = witness; | ||
Block.Transactions = TransactionHashes.Select(p => Transactions[p]).ToArray(); | ||
return Block; | ||
} | ||
|
||
} | ||
} |
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
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.