ethapi: Omit isSystemTx: "false" from JSON-RPC responses (#60)

This commit is contained in:
Adrian Sutton 2023-03-04 10:08:47 +10:00 committed by GitHub
parent 13e42b01a4
commit b9bbfdf372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -1464,7 +1464,10 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
srcHash := tx.SourceHash()
isSystemTx := tx.IsSystemTx()
result.SourceHash = &srcHash
result.IsSystemTx = &isSystemTx
if isSystemTx {
// Only include IsSystemTx when true
result.IsSystemTx = &isSystemTx
}
result.Mint = (*hexutil.Big)(tx.Mint())
if receipt != nil && receipt.DepositNonce != nil {
result.Nonce = hexutil.Uint64(*receipt.DepositNonce)

View File

@ -36,6 +36,15 @@ func TestNewRPCTransactionDepositTx(t *testing.T) {
require.Equal(t, got.Nonce, (hexutil.Uint64)(nonce), "newRPCTransaction().Mint = %v, want %v", got.Nonce, nonce)
}
func TestNewRPCTransactionOmitIsSystemTxFalse(t *testing.T) {
tx := types.NewTx(&types.DepositTx{
IsSystemTransaction: false,
})
got := newRPCTransaction(tx, common.Hash{}, uint64(12), uint64(1), big.NewInt(0), &params.ChainConfig{}, nil)
require.Nil(t, got.IsSystemTx, "should omit IsSystemTx when false")
}
func TestUnmarshalRpcDepositTx(t *testing.T) {
tests := []struct {
name string