You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
995 B

  1. package txselector
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "testing"
  6. "github.com/hermeznetwork/hermez-node/db/l2db"
  7. "github.com/hermeznetwork/hermez-node/db/statedb"
  8. "github.com/stretchr/testify/assert"
  9. "github.com/stretchr/testify/require"
  10. )
  11. func TestGetL2TxSelection(t *testing.T) {
  12. dir, err := ioutil.TempDir("", "tmpdb")
  13. require.Nil(t, err)
  14. sdb, err := statedb.NewStateDB(dir, false, 0)
  15. assert.Nil(t, err)
  16. testL2DB := &l2db.L2DB{}
  17. // initTestDB(testL2DB, sdb)
  18. txselDir, err := ioutil.TempDir("", "tmpTxSelDB")
  19. require.Nil(t, err)
  20. txsel, err := NewTxSelector(txselDir, sdb, testL2DB, 3, 3, 3)
  21. assert.Nil(t, err)
  22. fmt.Println(txsel)
  23. // txs, err := txsel.GetL2TxSelection(0)
  24. // assert.Nil(t, err)
  25. // for _, tx := range txs {
  26. // fmt.Println(tx.FromIdx, tx.ToIdx, tx.AbsoluteFee)
  27. // }
  28. // assert.Equal(t, 3, len(txs))
  29. // assert.Equal(t, uint64(6), txs[0].AbsoluteFee)
  30. // assert.Equal(t, uint64(5), txs[1].AbsoluteFee)
  31. // assert.Equal(t, uint64(4), txs[2].AbsoluteFee)
  32. }