-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CreateStandardMultisigAccount (#2343)
* Add CreateStandardMultisigAccount * plural * dotnet-format * Rename * Use CreateArray() * Fix UT Co-authored-by: Erik Zhang <erik@neo.org>
- Loading branch information
Showing
4 changed files
with
58 additions
and
12 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
50 changes: 50 additions & 0 deletions
50
tests/neo.UnitTests/SmartContract/UT_ApplicationEngine.Contract.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Neo.SmartContract; | ||
using Neo.VM; | ||
using System.Linq; | ||
|
||
namespace Neo.UnitTests.SmartContract | ||
{ | ||
public partial class UT_ApplicationEngine | ||
{ | ||
[TestMethod] | ||
public void TestCreateStandardAccount() | ||
{ | ||
var settings = ProtocolSettings.Default; | ||
using var engine = ApplicationEngine.Create(TriggerType.Application, null, null, settings: TestBlockchain.TheNeoSystem.Settings, gas: 1100_00000000); | ||
|
||
using var script = new ScriptBuilder(); | ||
script.EmitSysCall(ApplicationEngine.System_Contract_CreateStandardAccount, settings.StandbyCommittee[0].EncodePoint(true)); | ||
engine.LoadScript(script.ToArray()); | ||
|
||
Assert.AreEqual(VMState.HALT, engine.Execute()); | ||
|
||
var result = engine.ResultStack.Pop(); | ||
new UInt160(result.GetSpan()).Should().Be(Contract.CreateSignatureRedeemScript(settings.StandbyCommittee[0]).ToScriptHash()); | ||
} | ||
|
||
[TestMethod] | ||
public void TestCreateStandardMultisigAccount() | ||
{ | ||
var settings = ProtocolSettings.Default; | ||
using var engine = ApplicationEngine.Create(TriggerType.Application, null, null, settings: TestBlockchain.TheNeoSystem.Settings, gas: 1100_00000000); | ||
|
||
using var script = new ScriptBuilder(); | ||
script.EmitSysCall(ApplicationEngine.System_Contract_CreateMultisigAccount, new object[] | ||
{ | ||
2, | ||
3, | ||
settings.StandbyCommittee[0].EncodePoint(true), | ||
settings.StandbyCommittee[1].EncodePoint(true), | ||
settings.StandbyCommittee[2].EncodePoint(true) | ||
}); | ||
engine.LoadScript(script.ToArray()); | ||
|
||
Assert.AreEqual(VMState.HALT, engine.Execute()); | ||
|
||
var result = engine.ResultStack.Pop(); | ||
new UInt160(result.GetSpan()).Should().Be(Contract.CreateMultiSigRedeemScript(2, settings.StandbyCommittee.Take(3).ToArray()).ToScriptHash()); | ||
} | ||
} | ||
} |
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