Skip to content

Commit

Permalink
Sync neo (#631)
Browse files Browse the repository at this point in the history
* Sync neo

* Update Neo.Compiler.CSharp.csproj

* Fix UT

* Remove method
  • Loading branch information
shargon authored May 22, 2021
1 parent 6676148 commit edba39b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Neo.Compiler.CSharp/Neo.Compiler.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.9.0" />
<PackageReference Include="Neo" Version="3.0.0-rc2" />
<PackageReference Include="Neo" Version="3.0.0-CI01278" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21216.1" />
</ItemGroup>

Expand Down
4 changes: 4 additions & 0 deletions src/Neo.SmartContract.Framework/Native/StdLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public static class StdLib

public static extern string Base58Encode(ByteString input);

public static extern string Base58CheckEncode(ByteString input);

public static extern ByteString Base58CheckDecode(string input);

public static extern string Itoa(BigInteger value, int @base = 10);

public static extern string Itoa(int value, int @base = 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void Init()
var snapshot = new TestDataCache(null);

_engine = new TestEngine(TriggerType.Application, snapshot: snapshot);
_engine.AddEntryScript("./TestClasses/Contract_StdLib.cs");
Assert.IsTrue(_engine.AddEntryScript("./TestClasses/Contract_StdLib.cs").Success);
scriptHash = _engine.Nef.Script.ToScriptHash();

snapshot.ContractAdd(new ContractState()
Expand Down Expand Up @@ -101,6 +101,30 @@ public void Base58EncodeTest()
Assert.AreEqual("3yZe7d", item.GetString());
}

[TestMethod]
public void Base58CheckEncodeTest()
{
_engine.Reset();
var result = _engine.ExecuteTestCaseStandard("base58CheckEncode", "test");
Assert.AreEqual(VMState.HALT, _engine.State);
Assert.AreEqual(1, result.Count);

var item = result.Pop<VM.Types.ByteString>();
Assert.AreEqual("LUC1eAJa5jW", item.GetString());
}

[TestMethod]
public void Base58CheckDecodeTest()
{
_engine.Reset();
var result = _engine.ExecuteTestCaseStandard("base58CheckDecode", "LUC1eAJa5jW");
Assert.AreEqual(VMState.HALT, _engine.State);
Assert.AreEqual(1, result.Count);

var item = result.Pop<VM.Types.Buffer>();
Assert.AreEqual("test", item.GetString());
}

[TestMethod]
public void MemoryCompareTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ namespace Neo.SmartContract.Framework.UnitTests.TestClasses
{
public class Contract_Binary : SmartContract
{
public static string base58CheckEncode(ByteString input)
{
return StdLib.Base58CheckEncode(input);
}

public static byte[] base58CheckDecode(string input)
{
return (byte[])StdLib.Base58CheckDecode(input);
}

public static byte[] base64Decode(string input)
{
return (byte[])StdLib.Base64Decode(input);
Expand Down

0 comments on commit edba39b

Please sign in to comment.