mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
tests: update remaining tests for 89c2627a
This commit is contained in:
parent
25661b25a9
commit
2c819dd5ac
10 changed files with 101 additions and 101 deletions
|
|
@ -91,10 +91,10 @@ var bindTests = []struct {
|
|||
sim := backends.NewSimulatedBackend(types.GenesisAlloc{auth.From: {Balance: big.NewInt(10000000000000000)}}, 10000000)
|
||||
defer sim.Close()
|
||||
|
||||
maxUint256 := uint256.MustFromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
||||
maxU256 := uint256.MustFromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
||||
|
||||
// Deploy an interaction tester contract and call a transaction on it
|
||||
_, _, interactor, err := DeployToken(auth, sim, maxUint256, "TestToken", 19, "Test")
|
||||
_, _, interactor, err := DeployToken(auth, sim, maxU256, "TestToken", 19, "Test")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to deploy interactor contract: %v", err)
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ var bindTests = []struct {
|
|||
toKey, _ := crypto.GenerateKey()
|
||||
toAddr := crypto.PubkeyToAddress(toKey.PublicKey)
|
||||
|
||||
transferValue := maxUint256
|
||||
transferValue := maxU256
|
||||
_, err = interactor.Transfer(auth, toAddr, transferValue)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to transfer tokens: %v", err)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -202,7 +203,7 @@ func TestUnpackIndexedStringTyLogIntoMap(t *testing.T) {
|
|||
expectedReceivedMap := map[string]interface{}{
|
||||
"name": hash,
|
||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||
"amount": big.NewInt(1),
|
||||
"amount": uint256.NewInt(1),
|
||||
"memo": []byte{88},
|
||||
}
|
||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||
|
|
@ -246,7 +247,7 @@ func TestUnpackIndexedSliceTyLogIntoMap(t *testing.T) {
|
|||
expectedReceivedMap := map[string]interface{}{
|
||||
"names": hash,
|
||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||
"amount": big.NewInt(1),
|
||||
"amount": uint256.NewInt(1),
|
||||
"memo": []byte{88},
|
||||
}
|
||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||
|
|
@ -272,7 +273,7 @@ func TestUnpackIndexedArrayTyLogIntoMap(t *testing.T) {
|
|||
expectedReceivedMap := map[string]interface{}{
|
||||
"addresses": hash,
|
||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||
"amount": big.NewInt(1),
|
||||
"amount": uint256.NewInt(1),
|
||||
"memo": []byte{88},
|
||||
}
|
||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||
|
|
@ -299,7 +300,7 @@ func TestUnpackIndexedFuncTyLogIntoMap(t *testing.T) {
|
|||
expectedReceivedMap := map[string]interface{}{
|
||||
"function": functionTy,
|
||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||
"amount": big.NewInt(1),
|
||||
"amount": uint256.NewInt(1),
|
||||
"memo": []byte{88},
|
||||
}
|
||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||
|
|
@ -322,7 +323,7 @@ func TestUnpackIndexedBytesTyLogIntoMap(t *testing.T) {
|
|||
expectedReceivedMap := map[string]interface{}{
|
||||
"content": hash,
|
||||
"sender": common.HexToAddress("0x376c47978271565f56DEB45495afa69E59c16Ab2"),
|
||||
"amount": big.NewInt(1),
|
||||
"amount": uint256.NewInt(1),
|
||||
"memo": []byte{88},
|
||||
}
|
||||
unpackAndCheck(t, bc, expectedReceivedMap, mockLog)
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ var (
|
|||
|
||||
// DBStats is an auto generated low-level Go binding around an user-defined struct.
|
||||
type DBStats struct {
|
||||
Gets *big.Int
|
||||
Inserts *big.Int
|
||||
Mods *big.Int
|
||||
Gets *uint256.Int
|
||||
Inserts *uint256.Int
|
||||
Mods *uint256.Int
|
||||
}
|
||||
|
||||
// DBMetaData contains all meta data concerning the DB contract.
|
||||
|
|
@ -64,7 +64,7 @@ func (c *DB) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
|
|||
// the contract method with ID 0x9507d39a.
|
||||
//
|
||||
// Solidity: function get(uint256 k) returns(uint256)
|
||||
func (dB *DB) PackGet(k *big.Int) []byte {
|
||||
func (dB *DB) PackGet(k *uint256.Int) []byte {
|
||||
enc, err := dB.abi.Pack("get", k)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -76,12 +76,12 @@ func (dB *DB) PackGet(k *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x9507d39a.
|
||||
//
|
||||
// Solidity: function get(uint256 k) returns(uint256)
|
||||
func (dB *DB) UnpackGet(data []byte) (*big.Int, error) {
|
||||
func (dB *DB) UnpackGet(data []byte) (*uint256.Int, error) {
|
||||
out, err := dB.abi.Unpack("get", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
||||
|
|
@ -100,9 +100,9 @@ func (dB *DB) PackGetNamedStatParams() []byte {
|
|||
// GetNamedStatParamsOutput serves as a container for the return parameters of contract
|
||||
// method GetNamedStatParams.
|
||||
type GetNamedStatParamsOutput struct {
|
||||
Gets *big.Int
|
||||
Inserts *big.Int
|
||||
Mods *big.Int
|
||||
Gets *uint256.Int
|
||||
Inserts *uint256.Int
|
||||
Mods *uint256.Int
|
||||
}
|
||||
|
||||
// UnpackGetNamedStatParams is the Go binding that unpacks the parameters returned
|
||||
|
|
@ -115,9 +115,9 @@ func (dB *DB) UnpackGetNamedStatParams(data []byte) (GetNamedStatParamsOutput, e
|
|||
if err != nil {
|
||||
return *outstruct, err
|
||||
}
|
||||
outstruct.Gets = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
outstruct.Inserts = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
|
||||
outstruct.Mods = abi.ConvertType(out[2], new(big.Int)).(*big.Int)
|
||||
outstruct.Gets = abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
outstruct.Inserts = abi.ConvertType(out[1], new(uint256.Int)).(*uint256.Int)
|
||||
outstruct.Mods = abi.ConvertType(out[2], new(uint256.Int)).(*uint256.Int)
|
||||
return *outstruct, err
|
||||
|
||||
}
|
||||
|
|
@ -137,9 +137,9 @@ func (dB *DB) PackGetStatParams() []byte {
|
|||
// GetStatParamsOutput serves as a container for the return parameters of contract
|
||||
// method GetStatParams.
|
||||
type GetStatParamsOutput struct {
|
||||
Arg0 *big.Int
|
||||
Arg1 *big.Int
|
||||
Arg2 *big.Int
|
||||
Arg0 *uint256.Int
|
||||
Arg1 *uint256.Int
|
||||
Arg2 *uint256.Int
|
||||
}
|
||||
|
||||
// UnpackGetStatParams is the Go binding that unpacks the parameters returned
|
||||
|
|
@ -152,9 +152,9 @@ func (dB *DB) UnpackGetStatParams(data []byte) (GetStatParamsOutput, error) {
|
|||
if err != nil {
|
||||
return *outstruct, err
|
||||
}
|
||||
outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int)
|
||||
outstruct.Arg2 = abi.ConvertType(out[2], new(big.Int)).(*big.Int)
|
||||
outstruct.Arg0 = abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
outstruct.Arg1 = abi.ConvertType(out[1], new(uint256.Int)).(*uint256.Int)
|
||||
outstruct.Arg2 = abi.ConvertType(out[2], new(uint256.Int)).(*uint256.Int)
|
||||
return *outstruct, err
|
||||
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ func (dB *DB) UnpackGetStatsStruct(data []byte) (DBStats, error) {
|
|||
// the contract method with ID 0x1d834a1b.
|
||||
//
|
||||
// Solidity: function insert(uint256 k, uint256 v) returns(uint256)
|
||||
func (dB *DB) PackInsert(k *big.Int, v *big.Int) []byte {
|
||||
func (dB *DB) PackInsert(k *uint256.Int, v *uint256.Int) []byte {
|
||||
enc, err := dB.abi.Pack("insert", k, v)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -200,20 +200,20 @@ func (dB *DB) PackInsert(k *big.Int, v *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x1d834a1b.
|
||||
//
|
||||
// Solidity: function insert(uint256 k, uint256 v) returns(uint256)
|
||||
func (dB *DB) UnpackInsert(data []byte) (*big.Int, error) {
|
||||
func (dB *DB) UnpackInsert(data []byte) (*uint256.Int, error) {
|
||||
out, err := dB.abi.Unpack("insert", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
||||
// DBInsert represents a Insert event raised by the DB contract.
|
||||
type DBInsert struct {
|
||||
Key *big.Int
|
||||
Value *big.Int
|
||||
Length *big.Int
|
||||
Key *uint256.Int
|
||||
Value *uint256.Int
|
||||
Length *uint256.Int
|
||||
Raw *types.Log // Blockchain specific contextual infos
|
||||
}
|
||||
|
||||
|
|
@ -254,8 +254,8 @@ func (dB *DB) UnpackInsertEvent(log *types.Log) (*DBInsert, error) {
|
|||
|
||||
// DBKeyedInsert represents a KeyedInsert event raised by the DB contract.
|
||||
type DBKeyedInsert struct {
|
||||
Key *big.Int
|
||||
Value *big.Int
|
||||
Key *uint256.Int
|
||||
Value *uint256.Int
|
||||
Raw *types.Log // Blockchain specific contextual infos
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ func (c *C) PackEmitOne() []byte {
|
|||
|
||||
// CBasic1 represents a basic1 event raised by the C contract.
|
||||
type CBasic1 struct {
|
||||
Id *big.Int
|
||||
Data *big.Int
|
||||
Id *uint256.Int
|
||||
Data *uint256.Int
|
||||
Raw *types.Log // Blockchain specific contextual infos
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ func (c *C) UnpackBasic1Event(log *types.Log) (*CBasic1, error) {
|
|||
// CBasic2 represents a basic2 event raised by the C contract.
|
||||
type CBasic2 struct {
|
||||
Flag bool
|
||||
Data *big.Int
|
||||
Data *uint256.Int
|
||||
Raw *types.Log // Blockchain specific contextual infos
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func (c *C1) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
|
|||
// contract deployment.
|
||||
//
|
||||
// Solidity: constructor(uint256 v1, uint256 v2) returns()
|
||||
func (c1 *C1) PackConstructor(v1 *big.Int, v2 *big.Int) []byte {
|
||||
func (c1 *C1) PackConstructor(v1 *uint256.Int, v2 *uint256.Int) []byte {
|
||||
enc, err := c1.abi.Pack("", v1, v2)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -73,7 +73,7 @@ func (c1 *C1) PackConstructor(v1 *big.Int, v2 *big.Int) []byte {
|
|||
// the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256 res)
|
||||
func (c1 *C1) PackDo(val *big.Int) []byte {
|
||||
func (c1 *C1) PackDo(val *uint256.Int) []byte {
|
||||
enc, err := c1.abi.Pack("Do", val)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -85,12 +85,12 @@ func (c1 *C1) PackDo(val *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256 res)
|
||||
func (c1 *C1) UnpackDo(data []byte) (*big.Int, error) {
|
||||
func (c1 *C1) UnpackDo(data []byte) (*uint256.Int, error) {
|
||||
out, err := c1.abi.Unpack("Do", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ func (c *C2) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
|
|||
// contract deployment.
|
||||
//
|
||||
// Solidity: constructor(uint256 v1, uint256 v2) returns()
|
||||
func (c2 *C2) PackConstructor(v1 *big.Int, v2 *big.Int) []byte {
|
||||
func (c2 *C2) PackConstructor(v1 *uint256.Int, v2 *uint256.Int) []byte {
|
||||
enc, err := c2.abi.Pack("", v1, v2)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -141,7 +141,7 @@ func (c2 *C2) PackConstructor(v1 *big.Int, v2 *big.Int) []byte {
|
|||
// the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256 res)
|
||||
func (c2 *C2) PackDo(val *big.Int) []byte {
|
||||
func (c2 *C2) PackDo(val *uint256.Int) []byte {
|
||||
enc, err := c2.abi.Pack("Do", val)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -153,12 +153,12 @@ func (c2 *C2) PackDo(val *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256 res)
|
||||
func (c2 *C2) UnpackDo(data []byte) (*big.Int, error) {
|
||||
func (c2 *C2) UnpackDo(data []byte) (*uint256.Int, error) {
|
||||
out, err := c2.abi.Unpack("Do", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ func (c *L1) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
|
|||
// the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l1 *L1) PackDo(val *big.Int) []byte {
|
||||
func (l1 *L1) PackDo(val *uint256.Int) []byte {
|
||||
enc, err := l1.abi.Pack("Do", val)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -205,12 +205,12 @@ func (l1 *L1) PackDo(val *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l1 *L1) UnpackDo(data []byte) (*big.Int, error) {
|
||||
func (l1 *L1) UnpackDo(data []byte) (*uint256.Int, error) {
|
||||
out, err := l1.abi.Unpack("Do", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ func (c *L2) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
|
|||
// the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l2 *L2) PackDo(val *big.Int) []byte {
|
||||
func (l2 *L2) PackDo(val *uint256.Int) []byte {
|
||||
enc, err := l2.abi.Pack("Do", val)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -260,12 +260,12 @@ func (l2 *L2) PackDo(val *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l2 *L2) UnpackDo(data []byte) (*big.Int, error) {
|
||||
func (l2 *L2) UnpackDo(data []byte) (*uint256.Int, error) {
|
||||
out, err := l2.abi.Unpack("Do", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ func (c *L2b) Instance(backend bind.ContractBackend, addr common.Address) *bind.
|
|||
// the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l2b *L2b) PackDo(val *big.Int) []byte {
|
||||
func (l2b *L2b) PackDo(val *uint256.Int) []byte {
|
||||
enc, err := l2b.abi.Pack("Do", val)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -315,12 +315,12 @@ func (l2b *L2b) PackDo(val *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l2b *L2b) UnpackDo(data []byte) (*big.Int, error) {
|
||||
func (l2b *L2b) UnpackDo(data []byte) (*uint256.Int, error) {
|
||||
out, err := l2b.abi.Unpack("Do", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
||||
|
|
@ -355,7 +355,7 @@ func (c *L3) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
|
|||
// the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l3 *L3) PackDo(val *big.Int) []byte {
|
||||
func (l3 *L3) PackDo(val *uint256.Int) []byte {
|
||||
enc, err := l3.abi.Pack("Do", val)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -367,12 +367,12 @@ func (l3 *L3) PackDo(val *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l3 *L3) UnpackDo(data []byte) (*big.Int, error) {
|
||||
func (l3 *L3) UnpackDo(data []byte) (*uint256.Int, error) {
|
||||
out, err := l3.abi.Unpack("Do", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
||||
|
|
@ -411,7 +411,7 @@ func (c *L4) Instance(backend bind.ContractBackend, addr common.Address) *bind.B
|
|||
// the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l4 *L4) PackDo(val *big.Int) []byte {
|
||||
func (l4 *L4) PackDo(val *uint256.Int) []byte {
|
||||
enc, err := l4.abi.Pack("Do", val)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -423,12 +423,12 @@ func (l4 *L4) PackDo(val *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l4 *L4) UnpackDo(data []byte) (*big.Int, error) {
|
||||
func (l4 *L4) UnpackDo(data []byte) (*uint256.Int, error) {
|
||||
out, err := l4.abi.Unpack("Do", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
||||
|
|
@ -466,7 +466,7 @@ func (c *L4b) Instance(backend bind.ContractBackend, addr common.Address) *bind.
|
|||
// the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l4b *L4b) PackDo(val *big.Int) []byte {
|
||||
func (l4b *L4b) PackDo(val *uint256.Int) []byte {
|
||||
enc, err := l4b.abi.Pack("Do", val)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -478,11 +478,11 @@ func (l4b *L4b) PackDo(val *big.Int) []byte {
|
|||
// from invoking the contract method with ID 0x2ad11272.
|
||||
//
|
||||
// Solidity: function Do(uint256 val) pure returns(uint256)
|
||||
func (l4b *L4b) UnpackDo(data []byte) (*big.Int, error) {
|
||||
func (l4b *L4b) UnpackDo(data []byte) (*uint256.Int, error) {
|
||||
out, err := l4b.abi.Unpack("Do", data)
|
||||
if err != nil {
|
||||
return new(big.Int), err
|
||||
return new(uint256.Int), err
|
||||
}
|
||||
out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int)
|
||||
out0 := abi.ConvertType(out[0], new(uint256.Int)).(*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ func (c *C) UnpackError(raw []byte) (any, error) {
|
|||
|
||||
// CBadThing represents a BadThing error raised by the C contract.
|
||||
type CBadThing struct {
|
||||
Arg1 *big.Int
|
||||
Arg2 *big.Int
|
||||
Arg3 *big.Int
|
||||
Arg1 *uint256.Int
|
||||
Arg2 *uint256.Int
|
||||
Arg3 *uint256.Int
|
||||
Arg4 bool
|
||||
}
|
||||
|
||||
|
|
@ -118,10 +118,10 @@ func (c *C) UnpackBadThingError(raw []byte) (*CBadThing, error) {
|
|||
|
||||
// CBadThing2 represents a BadThing2 error raised by the C contract.
|
||||
type CBadThing2 struct {
|
||||
Arg1 *big.Int
|
||||
Arg2 *big.Int
|
||||
Arg3 *big.Int
|
||||
Arg4 *big.Int
|
||||
Arg1 *uint256.Int
|
||||
Arg2 *uint256.Int
|
||||
Arg3 *uint256.Int
|
||||
Arg4 *uint256.Int
|
||||
}
|
||||
|
||||
// ErrorID returns the hash of canonical representation of the error's signature.
|
||||
|
|
@ -193,9 +193,9 @@ func (c2 *C2) UnpackError(raw []byte) (any, error) {
|
|||
|
||||
// C2BadThing represents a BadThing error raised by the C2 contract.
|
||||
type C2BadThing struct {
|
||||
Arg1 *big.Int
|
||||
Arg2 *big.Int
|
||||
Arg3 *big.Int
|
||||
Arg1 *uint256.Int
|
||||
Arg2 *uint256.Int
|
||||
Arg3 *uint256.Int
|
||||
Arg4 bool
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,11 +69,11 @@ func (myContract *MyContract) PackGetNums() []byte {
|
|||
// from invoking the contract method with ID 0xbd6d1007.
|
||||
//
|
||||
// Solidity: function GetNums() pure returns(uint256[5])
|
||||
func (myContract *MyContract) UnpackGetNums(data []byte) ([5]*big.Int, error) {
|
||||
func (myContract *MyContract) UnpackGetNums(data []byte) ([5]*uint256.Int, error) {
|
||||
out, err := myContract.abi.Unpack("GetNums", data)
|
||||
if err != nil {
|
||||
return *new([5]*big.Int), err
|
||||
return *new([5]*uint256.Int), err
|
||||
}
|
||||
out0 := *abi.ConvertType(out[0], new([5]*big.Int)).(*[5]*big.Int)
|
||||
out0 := *abi.ConvertType(out[0], new([5]*uint256.Int)).(*[5]*uint256.Int)
|
||||
return out0, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/ethclient/simulated"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
|
|
@ -75,7 +76,7 @@ func TestDeploymentLibraries(t *testing.T) {
|
|||
defer bindBackend.Backend.Close()
|
||||
|
||||
c := nested_libraries.NewC1()
|
||||
constructorInput := c.PackConstructor(big.NewInt(42), big.NewInt(1))
|
||||
constructorInput := c.PackConstructor(uint256.NewInt(42), uint256.NewInt(1))
|
||||
deploymentParams := &bind.DeploymentParams{
|
||||
Contracts: []*bind.MetaData{&nested_libraries.C1MetaData},
|
||||
Inputs: map[string][]byte{nested_libraries.C1MetaData.ID: constructorInput},
|
||||
|
|
@ -96,7 +97,7 @@ func TestDeploymentLibraries(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
doInput := c.PackDo(big.NewInt(1))
|
||||
doInput := c.PackDo(uint256.NewInt(1))
|
||||
contractAddr := res.Addresses[nested_libraries.C1MetaData.ID]
|
||||
callOpts := &bind.CallOpts{From: common.Address{}, Context: context.Background()}
|
||||
instance := c.Instance(bindBackend, contractAddr)
|
||||
|
|
@ -139,7 +140,7 @@ func TestDeploymentWithOverrides(t *testing.T) {
|
|||
}
|
||||
|
||||
c := nested_libraries.NewC1()
|
||||
constructorInput := c.PackConstructor(big.NewInt(42), big.NewInt(1))
|
||||
constructorInput := c.PackConstructor(uint256.NewInt(42), uint256.NewInt(1))
|
||||
overrides := res.Addresses
|
||||
|
||||
// deploy the contract
|
||||
|
|
@ -165,7 +166,7 @@ func TestDeploymentWithOverrides(t *testing.T) {
|
|||
}
|
||||
|
||||
// call the deployed contract and make sure it returns the correct result
|
||||
doInput := c.PackDo(big.NewInt(1))
|
||||
doInput := c.PackDo(uint256.NewInt(1))
|
||||
instance := c.Instance(bindBackend, res.Addresses[nested_libraries.C1MetaData.ID])
|
||||
callOpts := new(bind.CallOpts)
|
||||
internalCallCount, err := bind.Call(instance, callOpts, doInput, c.UnpackDo)
|
||||
|
|
@ -346,13 +347,13 @@ func TestErrors(t *testing.T) {
|
|||
if !ok {
|
||||
t.Fatalf("unexpected type for error")
|
||||
}
|
||||
if unpackedErr.Arg1.Cmp(big.NewInt(0)) != 0 {
|
||||
if unpackedErr.Arg1.Cmp(uint256.NewInt(0)) != 0 {
|
||||
t.Fatalf("bad unpacked error result: expected Arg1 field to be 0. got %s", unpackedErr.Arg1.String())
|
||||
}
|
||||
if unpackedErr.Arg2.Cmp(big.NewInt(1)) != 0 {
|
||||
if unpackedErr.Arg2.Cmp(uint256.NewInt(1)) != 0 {
|
||||
t.Fatalf("bad unpacked error result: expected Arg2 field to be 1. got %s", unpackedErr.Arg2.String())
|
||||
}
|
||||
if unpackedErr.Arg3.Cmp(big.NewInt(2)) != 0 {
|
||||
if unpackedErr.Arg3.Cmp(uint256.NewInt(2)) != 0 {
|
||||
t.Fatalf("bad unpacked error result: expected Arg3 to be 2. got %s", unpackedErr.Arg3.String())
|
||||
}
|
||||
if unpackedErr.Arg4 != false {
|
||||
|
|
|
|||
|
|
@ -1014,8 +1014,6 @@ func TestPackAndUnpackIncompatibleNumber(t *testing.T) {
|
|||
}
|
||||
maxU64Plus1 := new(big.Int).Add(maxU64, big.NewInt(1))
|
||||
|
||||
// maxU256 := uint256.MustFromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
||||
|
||||
cases := []struct {
|
||||
decodeType string
|
||||
inputValue *big.Int
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@
|
|||
package fourbyte
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
func verify(t *testing.T, jsondata, calldata string, exp []interface{}) {
|
||||
|
|
@ -64,7 +64,7 @@ func TestNewUnpacker(t *testing.T) {
|
|||
// 0x123, [0x456, 0x789], "1234567890", "Hello, world!"
|
||||
"8be65246" + "00000000000000000000000000000000000000000000000000000000000001230000000000000000000000000000000000000000000000000000000000000080313233343536373839300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000004560000000000000000000000000000000000000000000000000000000000000789000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20776f726c642100000000000000000000000000000000000000",
|
||||
[]interface{}{
|
||||
big.NewInt(0x123),
|
||||
uint256.NewInt(0x123),
|
||||
[]uint32{0x456, 0x789},
|
||||
[10]byte{49, 50, 51, 52, 53, 54, 55, 56, 57, 48},
|
||||
common.Hex2Bytes("48656c6c6f2c20776f726c6421"),
|
||||
|
|
@ -76,19 +76,19 @@ func TestNewUnpacker(t *testing.T) {
|
|||
[]interface{}{
|
||||
[]byte{0x64, 0x61, 0x76, 0x65},
|
||||
true,
|
||||
[]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)},
|
||||
[]*uint256.Int{uint256.NewInt(1), uint256.NewInt(2), uint256.NewInt(3)},
|
||||
},
|
||||
}, {
|
||||
`[{"type":"function","name":"send","inputs":[{"type":"uint256"}]}]`,
|
||||
"a52c101e0000000000000000000000000000000000000000000000000000000000000012",
|
||||
[]interface{}{big.NewInt(0x12)},
|
||||
[]interface{}{uint256.NewInt(0x12)},
|
||||
}, {
|
||||
`[{"type":"function","name":"compareAndApprove","inputs":[{"type":"address"},{"type":"uint256"},{"type":"uint256"}]}]`,
|
||||
"751e107900000000000000000000000000000133700000deadbeef00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
|
||||
[]interface{}{
|
||||
common.HexToAddress("0x00000133700000deadbeef000000000000000000"),
|
||||
new(big.Int).SetBytes([]byte{0x00}),
|
||||
big.NewInt(0x1),
|
||||
new(uint256.Int).SetBytes([]byte{0x00}),
|
||||
uint256.NewInt(0x1),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue