types: add gid field

This commit is contained in:
c9s 2022-06-01 15:51:32 +08:00
parent 279e4d8682
commit bdc76e8db6
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
4 changed files with 14 additions and 5 deletions

View File

@ -38,7 +38,7 @@ func prepareDB(t *testing.T) (*rockhopper.DB, error) {
ctx := context.Background()
err = rockhopper.Up(ctx, db, migrations, 0, 0)
assert.NoError(t, err)
assert.NoError(t, err, "should migrate successfully")
return db, err
}

View File

@ -25,19 +25,24 @@ func TestMarginService(t *testing.T) {
ex.MarginSettings.IsIsolatedMargin = true
ex.MarginSettings.IsolatedMarginSymbol = "DOTUSDT"
logrus.SetLevel(logrus.ErrorLevel)
db, err := prepareDB(t)
assert.NoError(t, err)
if err != nil {
t.Fatal(err)
t.Fail()
return
}
defer db.Close()
ctx := context.Background()
logrus.SetLevel(logrus.DebugLevel)
dbx := sqlx.NewDb(db.DB, "sqlite3")
service := &MarginService{DB: dbx}
logrus.SetLevel(logrus.DebugLevel)
err = service.Sync(ctx, ex, "USDT", time.Date(2022, time.February, 1, 0, 0, 0, 0, time.UTC))
assert.NoError(t, err)

View File

@ -58,7 +58,7 @@ func Test_fieldsNamesOf(t *testing.T) {
{
name: "MarginInterest",
args: args{record: &types.MarginInterest{}},
want: []string{"exchange", "asset", "principle", "interest", "interest_rate", "isolated_symbol", "time"},
want: []string{"gid", "exchange", "asset", "principle", "interest", "interest_rate", "isolated_symbol", "time"},
},
}
for _, tt := range tests {

View File

@ -60,6 +60,7 @@ type MarginBorrowRepayService interface {
}
type MarginInterest struct {
GID uint64 `json:"gid" db:"gid"`
Exchange ExchangeName `json:"exchange" db:"exchange"`
Asset string `json:"asset" db:"asset"`
Principle fixedpoint.Value `json:"principle" db:"principle"`
@ -70,6 +71,7 @@ type MarginInterest struct {
}
type MarginLoan struct {
GID uint64 `json:"gid" db:"gid"`
Exchange ExchangeName `json:"exchange" db:"exchange"`
TransactionID uint64 `json:"transactionID" db:"transaction_id"`
Asset string `json:"asset" db:"asset"`
@ -79,6 +81,7 @@ type MarginLoan struct {
}
type MarginRepay struct {
GID uint64 `json:"gid" db:"gid"`
Exchange ExchangeName `json:"exchange" db:"exchange"`
TransactionID uint64 `json:"transactionID" db:"transaction_id"`
Asset string `json:"asset" db:"asset"`
@ -88,6 +91,7 @@ type MarginRepay struct {
}
type MarginLiquidation struct {
GID uint64 `json:"gid" db:"gid"`
Exchange ExchangeName `json:"exchange" db:"exchange"`
AveragePrice fixedpoint.Value `json:"averagePrice" db:"average_price"`
ExecutedQuantity fixedpoint.Value `json:"executedQuantity" db:"executed_quantity"`