mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
Impl api get batch(es)
This commit is contained in:
@@ -71,10 +71,11 @@ func (b BigIntStr) Value() (driver.Value, error) {
|
||||
return base64.StdEncoding.EncodeToString(bigInt.Bytes()), nil
|
||||
}
|
||||
|
||||
// CollectedFees is used to retrieve common.batch.CollectedFee from the DB
|
||||
type CollectedFees map[common.TokenID]BigIntStr
|
||||
|
||||
// UnmarshalJSON unmarshals a json representation of map[common.TokenID]*big.Int
|
||||
func (c *CollectedFees) UnmarshalJSON(text []byte) error {
|
||||
fmt.Println(string(text))
|
||||
bigIntMap := make(map[common.TokenID]*big.Int)
|
||||
if err := json.Unmarshal(text, &bigIntMap); err != nil {
|
||||
return err
|
||||
@@ -86,19 +87,6 @@ func (c *CollectedFees) UnmarshalJSON(text []byte) error {
|
||||
}
|
||||
*c = CollectedFees(bStrMap)
|
||||
return nil
|
||||
// fmt.Println(string(text))
|
||||
// *b = BigIntStr(string(text))
|
||||
// return nil
|
||||
// bigInt := &big.Int{}
|
||||
// if err := bigInt.UnmarshalText(text); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// bigIntStr := NewBigIntStr(bigInt)
|
||||
// if bigIntStr == nil {
|
||||
// return nil
|
||||
// }
|
||||
// *b = *bigIntStr
|
||||
// return nil
|
||||
}
|
||||
|
||||
// HezEthAddr is used to scan/value Ethereum Address directly into strings that follow the Ethereum address hez fotmat (^hez:0x[a-fA-F0-9]{40}$) from/to sql DBs.
|
||||
|
||||
@@ -7,11 +7,10 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/iden3/go-iden3-crypto/babyjub"
|
||||
|
||||
ethCommon "github.com/ethereum/go-ethereum/common"
|
||||
dbUtils "github.com/hermeznetwork/hermez-node/db"
|
||||
_ "github.com/mattn/go-sqlite3" // sqlite driver
|
||||
"github.com/iden3/go-iden3-crypto/babyjub"
|
||||
_ "github.com/mattn/go-sqlite3" //nolint sqlite driver
|
||||
"github.com/russross/meddler"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -29,10 +28,10 @@ func TestMain(m *testing.M) {
|
||||
panic(err)
|
||||
}
|
||||
db, err = sql.Open("sqlite3", dir+"sqlite.db")
|
||||
defer os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer os.RemoveAll(dir) //nolint
|
||||
schema := `CREATE TABLE test (i BLOB);`
|
||||
if _, err := db.Exec(schema); err != nil {
|
||||
panic(err)
|
||||
|
||||
Reference in New Issue
Block a user