diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-06-10 15:14:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-10 15:14:42 +0800 |
commit | c039bb38d45d9d8efcd88e1342d35656651a8ac8 (patch) | |
tree | 4fac6d666221c972593eb7bef701dfeefe60ecc2 /accounts/abi/numbers_test.go | |
parent | 6886913fdf7feaf39c49f1afebae1ef8ea10b514 (diff) | |
parent | 89c6c5bb85ff24c152218f245fa366e733c951a7 (diff) | |
download | dexon-c039bb38d45d9d8efcd88e1342d35656651a8ac8.tar dexon-c039bb38d45d9d8efcd88e1342d35656651a8ac8.tar.gz dexon-c039bb38d45d9d8efcd88e1342d35656651a8ac8.tar.bz2 dexon-c039bb38d45d9d8efcd88e1342d35656651a8ac8.tar.lz dexon-c039bb38d45d9d8efcd88e1342d35656651a8ac8.tar.xz dexon-c039bb38d45d9d8efcd88e1342d35656651a8ac8.tar.zst dexon-c039bb38d45d9d8efcd88e1342d35656651a8ac8.zip |
Merge pull request #2653 from tbocek/develop
Negative numbers not properly converted in ABI encoding
Diffstat (limited to 'accounts/abi/numbers_test.go')
-rw-r--r-- | accounts/abi/numbers_test.go | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/accounts/abi/numbers_test.go b/accounts/abi/numbers_test.go index d66a43258..f409aa60f 100644 --- a/accounts/abi/numbers_test.go +++ b/accounts/abi/numbers_test.go @@ -26,48 +26,28 @@ import ( func TestNumberTypes(t *testing.T) { ubytes := make([]byte, 32) ubytes[31] = 1 - sbytesmin := []byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} unsigned := U256(big.NewInt(1)) if !bytes.Equal(unsigned, ubytes) { t.Errorf("expected %x got %x", ubytes, unsigned) } - - signed := S256(big.NewInt(1)) - if !bytes.Equal(signed, ubytes) { - t.Errorf("expected %x got %x", ubytes, unsigned) - } - - signed = S256(big.NewInt(-1)) - if !bytes.Equal(signed, sbytesmin) { - t.Errorf("expected %x got %x", ubytes, unsigned) - } } func TestPackNumber(t *testing.T) { ubytes := make([]byte, 32) ubytes[31] = 1 - sbytesmin := []byte{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} maxunsigned := []byte{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} - packed := packNum(reflect.ValueOf(1), IntTy) - if !bytes.Equal(packed, ubytes) { - t.Errorf("expected %x got %x", ubytes, packed) - } - packed = packNum(reflect.ValueOf(-1), IntTy) - if !bytes.Equal(packed, sbytesmin) { - t.Errorf("expected %x got %x", ubytes, packed) - } - packed = packNum(reflect.ValueOf(1), UintTy) + packed := packNum(reflect.ValueOf(1)) if !bytes.Equal(packed, ubytes) { t.Errorf("expected %x got %x", ubytes, packed) } - packed = packNum(reflect.ValueOf(-1), UintTy) + packed = packNum(reflect.ValueOf(-1)) if !bytes.Equal(packed, maxunsigned) { t.Errorf("expected %x got %x", maxunsigned, packed) } - packed = packNum(reflect.ValueOf("string"), UintTy) + packed = packNum(reflect.ValueOf("string")) if packed != nil { t.Errorf("expected 'string' to pack to nil. got %x instead", packed) } |