Inline packRevert function as only used in test

pull/30695/head
Antony Denyer 5 days ago
parent abab3441b6
commit b304b1325c
No known key found for this signature in database
GPG Key ID: 579B30F3FDE8F90A
  1. 10
      accounts/abi/abi.go
  2. 12
      internal/ethapi/api_test.go

@ -309,13 +309,3 @@ func UnpackRevert(data []byte) (string, error) {
return "", errors.New("invalid data for unpacking")
}
}
func PackRevert(revertMessage string) []byte {
stringType, _ := NewType("string", "", nil)
args := Arguments{
{Type: stringType},
}
encodedMessage, _ := args.Pack(revertMessage)
return append(revertSelector, encodedMessage...)
}

@ -643,6 +643,16 @@ func TestEstimateGas(t *testing.T) {
signer = types.HomesteadSigner{}
randomAccounts = newAccounts(2)
)
packRevert := func(revertMessage string) []byte {
var revertSelector = crypto.Keccak256([]byte("Error(string)"))[:4]
stringType, _ := abi.NewType("string", "", nil)
args := abi.Arguments{
{Type: stringType},
}
encodedMessage, _ := args.Pack(revertMessage)
return append(revertSelector, encodedMessage...)
}
api := NewBlockChainAPI(newTestBackend(t, genBlocks, genesis, beacon.New(ethash.NewFaker()), func(i int, b *core.BlockGen) {
// Transfer from account[0] to account[1]
@ -809,7 +819,7 @@ func TestEstimateGas(t *testing.T) {
},
},
blockOverrides: BlockOverrides{Number: (*hexutil.Big)(big.NewInt(11))},
expectErr: newRevertError(abi.PackRevert("block 11")),
expectErr: newRevertError(packRevert("block 11")),
},
}
for i, tc := range testSuite {

Loading…
Cancel
Save