2021-03-14 03:04:18 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
"github.com/c9s/bbgo/pkg/types"
|
2022-02-09 10:23:35 +00:00
|
|
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
2021-03-14 03:04:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestWithdrawService(t *testing.T) {
|
|
|
|
db, err := prepareDB(t)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
defer db.Close()
|
|
|
|
|
|
|
|
xdb := sqlx.NewDb(db.DB, "sqlite3")
|
|
|
|
service := &WithdrawService{DB: xdb}
|
|
|
|
|
|
|
|
err = service.Insert(types.Withdraw{
|
|
|
|
Exchange: types.ExchangeMax,
|
|
|
|
Asset: "BTC",
|
2022-02-09 10:23:35 +00:00
|
|
|
Amount: fixedpoint.NewFromFloat(0.0001),
|
2021-03-14 03:04:18 +00:00
|
|
|
Address: "test",
|
|
|
|
TransactionID: "01",
|
2022-02-09 10:23:35 +00:00
|
|
|
TransactionFee: fixedpoint.NewFromFloat(0.0001),
|
2021-03-14 03:04:18 +00:00
|
|
|
Network: "omni",
|
2021-05-19 17:32:26 +00:00
|
|
|
ApplyTime: types.Time(time.Now()),
|
2021-03-14 03:04:18 +00:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
withdraws, err := service.Query(types.ExchangeMax)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEmpty(t, withdraws)
|
|
|
|
assert.Equal(t, types.ExchangeMax, withdraws[0].Exchange)
|
|
|
|
}
|