Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test optimizer #1249

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ public class Contract_Types_BigInteger : SmartContract.Framework.SmartContract
[Integer("100000000000000000000000000")]
private static readonly BigInteger publicBigInteger = default!;

public static BigInteger SumOne()
{
return 1 + 1;
}
public static BigInteger SumOverflow()
{
var i = int.MaxValue;
return i + 1;
}
public static BigInteger Attribute() { return publicBigInteger; }
public static BigInteger Zero() { return BigInteger.Zero; }
public static BigInteger One() { return BigInteger.One; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public abstract class Contract_Types_BigInteger(Neo.SmartContract.Testing.SmartC
{
#region Compiled data

public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_Types_BigInteger"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""attribute"",""parameters"":[],""returntype"":""Integer"",""offset"":0,""safe"":false},{""name"":""zero"",""parameters"":[],""returntype"":""Integer"",""offset"":18,""safe"":false},{""name"":""one"",""parameters"":[],""returntype"":""Integer"",""offset"":20,""safe"":false},{""name"":""minusOne"",""parameters"":[],""returntype"":""Integer"",""offset"":22,""safe"":false},{""name"":""parse"",""parameters"":[{""name"":""value"",""type"":""String""}],""returntype"":""Integer"",""offset"":24,""safe"":false},{""name"":""convertFromChar"",""parameters"":[],""returntype"":""Integer"",""offset"":32,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"",""methods"":[""atoi""]}],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}");
public static Neo.SmartContract.Manifest.ContractManifest Manifest => Neo.SmartContract.Manifest.ContractManifest.Parse(@"{""name"":""Contract_Types_BigInteger"",""groups"":[],""features"":{},""supportedstandards"":[],""abi"":{""methods"":[{""name"":""sumOne"",""parameters"":[],""returntype"":""Integer"",""offset"":0,""safe"":false},{""name"":""sumOverflow"",""parameters"":[],""returntype"":""Integer"",""offset"":2,""safe"":false},{""name"":""attribute"",""parameters"":[],""returntype"":""Integer"",""offset"":61,""safe"":false},{""name"":""zero"",""parameters"":[],""returntype"":""Integer"",""offset"":79,""safe"":false},{""name"":""one"",""parameters"":[],""returntype"":""Integer"",""offset"":81,""safe"":false},{""name"":""minusOne"",""parameters"":[],""returntype"":""Integer"",""offset"":83,""safe"":false},{""name"":""parse"",""parameters"":[{""name"":""value"",""type"":""String""}],""returntype"":""Integer"",""offset"":85,""safe"":false},{""name"":""convertFromChar"",""parameters"":[],""returntype"":""Integer"",""offset"":93,""safe"":false}],""events"":[]},""permissions"":[{""contract"":""0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"",""methods"":[""atoi""]}],""trusts"":[],""extra"":{""nef"":{""optimization"":""All""}}}");

/// <summary>
/// Optimization: "All"
/// </summary>
public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable<Neo.SmartContract.NefFile>(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHA7znO4OTpJcbCoGp54UQN2G/OrARhdG9pAQABDwAAIwQAAADk0gzI3NK3UgAAAAAAQBBAEUAPQFcAAXg3AABAAEFASEeaMA=="));
public static Neo.SmartContract.NefFile Nef => Neo.IO.Helper.AsSerializable<Neo.SmartContract.NefFile>(Convert.FromBase64String(@"TkVGM1Rlc3RpbmdFbmdpbmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHA7znO4OTpJcbCoGp54UQN2G/OrARhdG9pAQABDwAAYBJAVwEAAv///39waBGeSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn0AEAAAA5NIMyNzSt1IAAAAAAEAQQBFAD0BXAAF4NwAAQABBQLKPnJE="));

#endregion

Expand Down Expand Up @@ -78,6 +78,47 @@ public abstract class Contract_Types_BigInteger(Neo.SmartContract.Testing.SmartC
[DisplayName("parse")]
public abstract BigInteger? Parse(string? value);

/// <summary>
/// Unsafe method
/// </summary>
/// <remarks>
/// Script: EkA=
/// 00 : PUSH2 [1 datoshi]
/// 01 : RET [0 datoshi]
/// </remarks>
[DisplayName("sumOne")]
public abstract BigInteger? SumOne();

/// <summary>
/// Unsafe method
/// </summary>
/// <remarks>
/// Script: VwEAAv///39waBGeSgIAAACALgQiCkoC////fzIeA/////8AAAAAkUoC////fzIMAwAAAAABAAAAn0A=
/// 00 : INITSLOT 0100 [64 datoshi]
/// 03 : PUSHINT32 FFFFFF7F [1 datoshi]
/// 08 : STLOC0 [2 datoshi]
/// 09 : LDLOC0 [2 datoshi]
/// 0A : PUSH1 [1 datoshi]
/// 0B : ADD [8 datoshi]
/// 0C : DUP [2 datoshi]
/// 0D : PUSHINT32 00000080 [1 datoshi]
/// 12 : JMPGE 04 [2 datoshi]
/// 14 : JMP 0A [2 datoshi]
/// 16 : DUP [2 datoshi]
/// 17 : PUSHINT32 FFFFFF7F [1 datoshi]
/// 1C : JMPLE 1E [2 datoshi]
/// 1E : PUSHINT64 FFFFFFFF00000000 [1 datoshi]
/// 27 : AND [8 datoshi]
/// 28 : DUP [2 datoshi]
/// 29 : PUSHINT32 FFFFFF7F [1 datoshi]
/// 2E : JMPLE 0C [2 datoshi]
/// 30 : PUSHINT64 0000000001000000 [1 datoshi]
/// 39 : SUB [8 datoshi]
/// 3A : RET [0 datoshi]
/// </remarks>
[DisplayName("sumOverflow")]
public abstract BigInteger? SumOverflow();

/// <summary>
/// Unsafe method
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions tests/Neo.Compiler.CSharp.UnitTests/UnitTest_Types_BigInteger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ namespace Neo.Compiler.CSharp.UnitTests
[TestClass]
public class UnitTest_Types_BigInteger : DebugAndTestBase<Contract_Types_BigInteger>
{
[TestMethod]
public void BigInteger_SumOne()
{
Assert.AreEqual(2, Contract.SumOne());
AssertGasConsumed(984060);

Assert.AreEqual(-2147483648, Contract.SumOverflow());
AssertGasConsumed(987360);
}

[TestMethod]
public void BigInteger_Test()
{
Expand Down
Loading