Add TxID calculation & New{Layer}Tx Type

Add TxID calculation & New{Layer}Tx Type

New{Layer}Tx methods that compute the `TxID` & `TxType` values from the
transaction values:
- NewL1Tx
- NewL2Tx
- NewPoolL2Tx

Add TxID Scanner & Valuer for database/sql

HistoryDB & L2DB & API packages tests will need to be addapted to the
TestTransaction generation once is done.
This commit is contained in:
arnaucube
2020-09-30 14:05:51 +02:00
parent c6f70f3177
commit 9bb4a4ec1b
21 changed files with 422 additions and 131 deletions

20
common/l2tx_test.go Normal file
View File

@@ -0,0 +1,20 @@
package common
import (
"math/big"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewL2Tx(t *testing.T) {
l2Tx := &L2Tx{
FromIdx: 87654,
ToIdx: 300,
Amount: big.NewInt(4),
Nonce: 144,
}
l2Tx, err := NewL2Tx(l2Tx)
assert.Nil(t, err)
assert.Equal(t, "0x020000000156660000000090", l2Tx.TxID.String())
}