Skip to content

Commit

Permalink
fix: now that rlpae deserializes big.Int(0) from 0x00 more correctly,…
Browse files Browse the repository at this point in the history
… the Equal method on the Tx struct is unnecessary
  • Loading branch information
randomshinichi committed Aug 13, 2019
1 parent 6d720ca commit b622992
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
15 changes: 0 additions & 15 deletions aeternity/tx_spend.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package aeternity

import (
"bytes"
"io"
"math/big"

Expand All @@ -21,20 +20,6 @@ type SpendTx struct {
Nonce uint64
}

// Equal compares the receiver to another struct of the same type. This is
// needed because several types in Golang are difficult to compare, especially
// using reflect.DeepEqual.
func (tx *SpendTx) Equal(other *SpendTx) (equal bool) {
equal = (tx.SenderID == other.SenderID &&
tx.RecipientID == other.RecipientID &&
tx.Amount.Cmp(&other.Amount) == 0 &&
tx.Fee.Cmp(&other.Fee) == 0 &&
bytes.Equal(tx.Payload, other.Payload) &&
tx.TTL == other.TTL &&
tx.Nonce == other.Nonce)
return
}

// EncodeRLP implements rlp.Encoder
func (tx *SpendTx) EncodeRLP(w io.Writer) (err error) {
// build id for the sender
Expand Down
3 changes: 2 additions & 1 deletion aeternity/tx_spend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"math/big"
"reflect"
"testing"

"github.com/aeternity/aepp-sdk-go/utils"
Expand Down Expand Up @@ -140,7 +141,7 @@ func TestSpendTx_DecodeRLP(t *testing.T) {
if err != nil {
t.Error(err)
}
if !(gotTx.Equal(&tt.wantTx)) {
if !(reflect.DeepEqual(gotTx, tt.wantTx)) {
t.Errorf("Deserialization resulted in different structs: got %+v, want %+v", gotTx, tt.wantTx)
}
})
Expand Down

0 comments on commit b622992

Please sign in to comment.