Inline packRevert function as only used in test

This commit is contained in:
Antony Denyer 2024-11-01 08:50:28 +00:00
parent abab3441b6
commit b304b1325c
No known key found for this signature in database
GPG key ID: 579B30F3FDE8F90A
2 changed files with 11 additions and 11 deletions

View file

@ -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...)
}

View file

@ -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 {