mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
Inline packRevert function as only used in test
This commit is contained in:
parent
abab3441b6
commit
b304b1325c
2 changed files with 11 additions and 11 deletions
|
|
@ -309,13 +309,3 @@ func UnpackRevert(data []byte) (string, error) {
|
||||||
return "", errors.New("invalid data for unpacking")
|
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{}
|
signer = types.HomesteadSigner{}
|
||||||
randomAccounts = newAccounts(2)
|
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) {
|
api := NewBlockChainAPI(newTestBackend(t, genBlocks, genesis, beacon.New(ethash.NewFaker()), func(i int, b *core.BlockGen) {
|
||||||
// Transfer from account[0] to account[1]
|
// Transfer from account[0] to account[1]
|
||||||
|
|
@ -809,7 +819,7 @@ func TestEstimateGas(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
blockOverrides: BlockOverrides{Number: (*hexutil.Big)(big.NewInt(11))},
|
blockOverrides: BlockOverrides{Number: (*hexutil.Big)(big.NewInt(11))},
|
||||||
expectErr: newRevertError(abi.PackRevert("block 11")),
|
expectErr: newRevertError(packRevert("block 11")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for i, tc := range testSuite {
|
for i, tc := range testSuite {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue