fix: resolve shared symbol mapping for token command (#22)
Build Docker Image / build (amd64) (push) Successful in 1m36s
Build Docker Image / build (amd64) (push) Successful in 1m36s
Co-authored-by: thuanle <tl@thuanle.me> Co-committed-by: thuanle <tl@thuanle.me>
This commit was merged in pull request #22.
This commit is contained in:
@@ -113,9 +113,15 @@ func TestCollectRichTokenData_FutureFailureStillKeepsSpot(t *testing.T) {
|
||||
defer func() { data.Market = orig }()
|
||||
|
||||
data.Market = &marketStub{
|
||||
spotPairs: map[string]bool{"ETHUSDT": true},
|
||||
futuresPairs: map[string]bool{"ETHUSDT": true},
|
||||
spotPrices: map[string]float64{"ETHUSDT": 3245},
|
||||
spotPairs: map[string]bool{
|
||||
"ETHUSDT": true,
|
||||
},
|
||||
futuresPairs: map[string]bool{
|
||||
"ETHUSDT": true,
|
||||
},
|
||||
spotPrices: map[string]float64{
|
||||
"ETHUSDT": 3245,
|
||||
},
|
||||
futurePrices: map[string]struct {
|
||||
price float64
|
||||
rate float64
|
||||
@@ -132,6 +138,67 @@ func TestCollectRichTokenData_FutureFailureStillKeepsSpot(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectRichTokenData_UsesSharedResolverMapping(t *testing.T) {
|
||||
orig := data.Market
|
||||
defer func() { data.Market = orig }()
|
||||
|
||||
data.Market = &marketStub{
|
||||
spotPairs: map[string]bool{
|
||||
"LUNAUSDT": true,
|
||||
},
|
||||
futuresPairs: map[string]bool{
|
||||
"LUNA2USDT": true,
|
||||
},
|
||||
spotPrices: map[string]float64{
|
||||
"LUNAUSDT": 0.49,
|
||||
},
|
||||
futurePrices: map[string]struct {
|
||||
price float64
|
||||
rate float64
|
||||
time int64
|
||||
}{
|
||||
"LUNA2USDT": {price: 0.50, rate: 0.0001, time: 1740000000000},
|
||||
},
|
||||
}
|
||||
|
||||
args := collectRichTokenData("LUNA2")
|
||||
if !args.HasFuture || !args.HasSpot {
|
||||
t.Fatalf("expected both future and mapped spot, got %+v", args)
|
||||
}
|
||||
if args.SpotPrice != 0.49 {
|
||||
t.Fatalf("expected mapped spot price 0.49, got %f", args.SpotPrice)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectRichTokenData_PrefixFutureMapsToSpot(t *testing.T) {
|
||||
orig := data.Market
|
||||
defer func() { data.Market = orig }()
|
||||
|
||||
data.Market = &marketStub{
|
||||
spotPairs: map[string]bool{
|
||||
"PEPEUSDT": true,
|
||||
},
|
||||
futuresPairs: map[string]bool{
|
||||
"1000PEPEUSDT": true,
|
||||
},
|
||||
spotPrices: map[string]float64{
|
||||
"PEPEUSDT": 0.000012,
|
||||
},
|
||||
futurePrices: map[string]struct {
|
||||
price float64
|
||||
rate float64
|
||||
time int64
|
||||
}{
|
||||
"1000PEPEUSDT": {price: 0.000013, rate: 0.0002, time: 1740000000000},
|
||||
},
|
||||
}
|
||||
|
||||
args := collectRichTokenData("PEPE")
|
||||
if !args.HasFuture || !args.HasSpot {
|
||||
t.Fatalf("expected both future and mapped spot for prefixed contract, got %+v", args)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectRichTokenData_AlphaUsesSymbolPrice(t *testing.T) {
|
||||
orig := data.Market
|
||||
defer func() { data.Market = orig }()
|
||||
|
||||
Reference in New Issue
Block a user