mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 19:36:44 +01:00
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:
27
common/tx_test.go
Normal file
27
common/tx_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"database/sql/driver"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestTxIDScannerValue(t *testing.T) {
|
||||
txid0 := &TxID{}
|
||||
txid1 := &TxID{}
|
||||
txid0B := [12]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
txid1B := [12]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
copy(txid0[:], txid0B[:])
|
||||
copy(txid1[:], txid1B[:])
|
||||
|
||||
var value driver.Valuer
|
||||
var scan sql.Scanner
|
||||
value = txid0
|
||||
scan = txid1
|
||||
fromDB, err := value.Value()
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, scan.Scan(fromDB))
|
||||
assert.Equal(t, value, scan)
|
||||
}
|
||||
Reference in New Issue
Block a user