diff --git a/cli/nep17_test.go b/cli/nep17_test.go index 3341b35a2..3994b318a 100644 --- a/cli/nep17_test.go +++ b/cli/nep17_test.go @@ -85,7 +85,7 @@ func TestNEP17Balance(t *testing.T) { } e.checkNextLine(t, "^\\s*$") - addr4, err := address.StringToUint160("NbxpLNCCSWZ9BkYpCYT8NfN1uoxq9Rfbrn") // deployed verify.go contract + addr4, err := address.StringToUint160("NWTDxsHVde5qSjRkTRUAg6i8xC3JSWEC9k") // deployed verify.go contract require.NoError(t, err) e.checkNextLine(t, "^Account "+address.Uint160ToString(addr4)) e.checkEOF(t) diff --git a/cli/testdata/wallet1_solo.json b/cli/testdata/wallet1_solo.json index 764d94cfa..050459eb0 100644 --- a/cli/testdata/wallet1_solo.json +++ b/cli/testdata/wallet1_solo.json @@ -61,7 +61,7 @@ "isdefault": false }, { - "address" : "NbxpLNCCSWZ9BkYpCYT8NfN1uoxq9Rfbrn", + "address" : "NWTDxsHVde5qSjRkTRUAg6i8xC3JSWEC9k", "key" : "6PYXDze5Ak4HahYKygcNzk6n65ACjWdDCYLSuKgA5KG8vyMJSFboUNSiPD", "label" : "", "contract" : { diff --git a/pkg/compiler/binary_expr_test.go b/pkg/compiler/binary_expr_test.go index 22bafd8a7..0afb2bcc2 100644 --- a/pkg/compiler/binary_expr_test.go +++ b/pkg/compiler/binary_expr_test.go @@ -361,3 +361,15 @@ func TestShortCircuit(t *testing.T) { eval(t, src, big.NewInt(17)) }) } + +func TestEmitBoolean(t *testing.T) { + src := `package foo + func Main() int { + a := true + if (a == true) == true { + return 42 + } + return 11 + }` + eval(t, src, big.NewInt(42)) +} diff --git a/pkg/compiler/for_test.go b/pkg/compiler/for_test.go index f2995cc3c..ab2a29fbe 100644 --- a/pkg/compiler/for_test.go +++ b/pkg/compiler/for_test.go @@ -209,7 +209,7 @@ func TestBoolAssign(t *testing.T) { return x } ` - eval(t, src, big.NewInt(1)) + eval(t, src, true) } func TestBoolCompare(t *testing.T) { diff --git a/pkg/compiler/import_test.go b/pkg/compiler/import_test.go index c72097a56..9080209f4 100644 --- a/pkg/compiler/import_test.go +++ b/pkg/compiler/import_test.go @@ -46,7 +46,7 @@ func TestMultipleDirFileImport(t *testing.T) { return ok } ` - eval(t, src, big.NewInt(1)) + eval(t, src, true) } func TestImportNameSameAsOwn(t *testing.T) { diff --git a/pkg/rpc/server/server_test.go b/pkg/rpc/server/server_test.go index c643aa790..9c90f3fdd 100644 --- a/pkg/rpc/server/server_test.go +++ b/pkg/rpc/server/server_test.go @@ -59,9 +59,9 @@ type rpcTestCase struct { check func(t *testing.T, e *executor, result interface{}) } -const testContractHash = "c6436aab21ebd15279b85af8d7b5808d38455b0a" -const deploymentTxHash = "050e2189d7cd7b719d9c4bbc525d3edcd89ffedb28cc974862d17dda14377612" -const genesisBlockHash = "41d1099030004d60f3b4b7ffe00bf184e84fac3a39ee7136c761e005f0186d93" +const testContractHash = "500858b96054d3c302078882c30e76915aac1c83" +const deploymentTxHash = "fbea49056332ecf1482568e24ed745151ed3fcacbb59afc22d9baff5346e6257" +const genesisBlockHash = "0542f4350c6e236d0509bcd98188b0034bfbecc1a0c7fcdb8e4295310d468b70" const verifyContractHash = "03ffc0897543b9b709e0f8cab4a7682dae0ba943" const verifyContractAVM = "570300412d51083021700c14aa8acf859d4fe402b34e673f2156821796a488ebdb30716813cedb2869db289740" @@ -1598,7 +1598,7 @@ func checkNep17Balances(t *testing.T, e *executor, acc interface{}) { }, { Asset: e.chain.UtilityTokenHash(), - Amount: "78994306100", + Amount: "78994294100", LastUpdated: 8, }}, Address: testchain.PrivateKeyByID(0).GetScriptHash().StringLE(), diff --git a/pkg/rpc/server/testdata/testblocks.acc b/pkg/rpc/server/testdata/testblocks.acc index b7bdeaecc..6fc740d62 100644 Binary files a/pkg/rpc/server/testdata/testblocks.acc and b/pkg/rpc/server/testdata/testblocks.acc differ diff --git a/pkg/vm/emit/emit.go b/pkg/vm/emit/emit.go index bee1b4c1a..31ea60697 100644 --- a/pkg/vm/emit/emit.go +++ b/pkg/vm/emit/emit.go @@ -33,9 +33,9 @@ func Opcodes(w *io.BinWriter, ops ...opcode.Opcode) { func Bool(w *io.BinWriter, ok bool) { if ok { Opcodes(w, opcode.PUSHT) - return + } else { + Opcodes(w, opcode.PUSHF) } - Opcodes(w, opcode.PUSHF) Instruction(w, opcode.CONVERT, []byte{byte(stackitem.BooleanT)}) } diff --git a/pkg/vm/emit/emit_test.go b/pkg/vm/emit/emit_test.go index be2aad6d0..7d1fd9aa2 100644 --- a/pkg/vm/emit/emit_test.go +++ b/pkg/vm/emit/emit_test.go @@ -9,6 +9,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/encoding/bigint" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" + "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -151,15 +152,17 @@ func TestEmitArray(t *testing.T) { assert.EqualValues(t, 2, res[1]) assert.EqualValues(t, []byte{0xCA, 0xFE}, res[2:4]) assert.EqualValues(t, opcode.PUSHT, res[4]) - assert.EqualValues(t, opcode.PUSHDATA1, res[5]) - assert.EqualValues(t, 3, res[6]) - assert.EqualValues(t, []byte("str"), res[7:10]) - assert.EqualValues(t, opcode.PUSH1, res[10]) - assert.EqualValues(t, opcode.PUSHNULL, res[11]) - assert.EqualValues(t, opcode.PUSH2, res[12]) - assert.EqualValues(t, opcode.PUSH1, res[13]) + assert.EqualValues(t, opcode.CONVERT, res[5]) + assert.EqualValues(t, stackitem.BooleanT, res[6]) + assert.EqualValues(t, opcode.PUSHDATA1, res[7]) + assert.EqualValues(t, 3, res[8]) + assert.EqualValues(t, []byte("str"), res[9:12]) + assert.EqualValues(t, opcode.PUSH1, res[12]) + assert.EqualValues(t, opcode.PUSHNULL, res[13]) assert.EqualValues(t, opcode.PUSH2, res[14]) - assert.EqualValues(t, opcode.PACK, res[15]) + assert.EqualValues(t, opcode.PUSH1, res[15]) + assert.EqualValues(t, opcode.PUSH2, res[16]) + assert.EqualValues(t, opcode.PACK, res[17]) }) t.Run("empty", func(t *testing.T) { @@ -181,8 +184,12 @@ func TestEmitBool(t *testing.T) { Bool(buf.BinWriter, true) Bool(buf.BinWriter, false) result := buf.Bytes() - assert.Equal(t, opcode.Opcode(result[0]), opcode.PUSH1) - assert.Equal(t, opcode.Opcode(result[1]), opcode.PUSH0) + assert.EqualValues(t, opcode.PUSH1, result[0]) + assert.EqualValues(t, opcode.CONVERT, result[1]) + assert.EqualValues(t, stackitem.BooleanT, result[2]) + assert.EqualValues(t, opcode.PUSH0, result[3]) + assert.EqualValues(t, opcode.CONVERT, result[4]) + assert.EqualValues(t, stackitem.BooleanT, result[5]) } func TestEmitOpcode(t *testing.T) {