@@ -38,6 +38,8 @@ func TestListingAttributes(t *testing.T) {
38
38
expectedSlug string
39
39
expectedPrice * repo.CurrencyValue
40
40
expectedAcceptedCurrencies []string
41
+ expectedCryptoDivisibility uint32
42
+ expectedCryptoCurrencyCode string
41
43
}{
42
44
{
43
45
fixtureName : "v3-physical-good" ,
@@ -53,6 +55,8 @@ func TestListingAttributes(t *testing.T) {
53
55
},
54
56
},
55
57
expectedAcceptedCurrencies : []string {"BCH" },
58
+ expectedCryptoDivisibility : 0 ,
59
+ expectedCryptoCurrencyCode : "" ,
56
60
},
57
61
{
58
62
fixtureName : "v4-physical-good" ,
@@ -68,6 +72,8 @@ func TestListingAttributes(t *testing.T) {
68
72
},
69
73
},
70
74
expectedAcceptedCurrencies : []string {"ZEC" , "LTC" , "BTC" , "BCH" },
75
+ expectedCryptoDivisibility : 0 ,
76
+ expectedCryptoCurrencyCode : "" ,
71
77
},
72
78
{
73
79
fixtureName : "v4-digital-good" ,
@@ -83,6 +89,8 @@ func TestListingAttributes(t *testing.T) {
83
89
},
84
90
},
85
91
expectedAcceptedCurrencies : []string {"ZEC" },
92
+ expectedCryptoDivisibility : 0 ,
93
+ expectedCryptoCurrencyCode : "" ,
86
94
},
87
95
{
88
96
fixtureName : "v4-service" ,
@@ -98,6 +106,8 @@ func TestListingAttributes(t *testing.T) {
98
106
},
99
107
},
100
108
expectedAcceptedCurrencies : []string {"ZEC" , "LTC" , "BCH" , "BTC" },
109
+ expectedCryptoDivisibility : 0 ,
110
+ expectedCryptoCurrencyCode : "" ,
101
111
},
102
112
{
103
113
fixtureName : "v4-cryptocurrency" ,
@@ -106,6 +116,8 @@ func TestListingAttributes(t *testing.T) {
106
116
expectedSlug : "ltc-xmr" ,
107
117
expectedPrice : nil ,
108
118
expectedAcceptedCurrencies : []string {"LTC" },
119
+ expectedCryptoDivisibility : 8 ,
120
+ expectedCryptoCurrencyCode : "XMR" ,
109
121
},
110
122
{
111
123
fixtureName : "v5-physical-good" ,
@@ -121,10 +133,13 @@ func TestListingAttributes(t *testing.T) {
121
133
},
122
134
},
123
135
expectedAcceptedCurrencies : []string {"BTC" , "BCH" , "ZEC" , "LTC" , "ETH" },
136
+ expectedCryptoDivisibility : 0 ,
137
+ expectedCryptoCurrencyCode : "" ,
124
138
},
125
139
}
126
140
127
141
for _ , e := range examples {
142
+ t .Logf ("example listing (%s)" , e .fixtureName )
128
143
var (
129
144
fixtureBytes = factory .MustLoadListingFixture (e .fixtureName )
130
145
l , err = repo .UnmarshalJSONListing (fixtureBytes )
@@ -134,19 +149,25 @@ func TestListingAttributes(t *testing.T) {
134
149
continue
135
150
}
136
151
if l .Metadata .Version != e .expectedResponse {
137
- t .Errorf ("expected example (%s) to have version response (%+v), but instead was (%+v)" , e . fixtureName , e .expectedResponse , l .Metadata .Version )
152
+ t .Errorf ("expected to have version response (%+v), but instead was (%+v)" , e .expectedResponse , l .Metadata .Version )
138
153
}
139
154
if title , _ := l .GetTitle (); title != e .expectedTitle {
140
- t .Errorf ("expected example (%s) to have title response (%+v), but instead was (%+v)" , e . fixtureName , e .expectedTitle , title )
155
+ t .Errorf ("expected to have title response (%+v), but instead was (%+v)" , e .expectedTitle , title )
141
156
}
142
157
if slug , _ := l .GetSlug (); slug != e .expectedSlug {
143
- t .Errorf ("expected example (%s) to have slug response (%+v), but instead was (%+v)" , e . fixtureName , e .expectedSlug , slug )
158
+ t .Errorf ("expected to have slug response (%+v), but instead was (%+v)" , e .expectedSlug , slug )
144
159
}
145
160
if price , _ := l .GetPrice (); ! price .Equal (e .expectedPrice ) {
146
- t .Errorf ("expected example (%s) to have price response (%+v), but instead was (%+v)" , e . fixtureName , e .expectedPrice , price )
161
+ t .Errorf ("expected to have price response (%+v), but instead was (%+v)" , e .expectedPrice , price )
147
162
}
148
163
if acceptedCurrencies , _ := l .GetAcceptedCurrencies (); len (acceptedCurrencies ) != len (e .expectedAcceptedCurrencies ) {
149
- t .Errorf ("expected example (%s) to have acceptedCurrencies response (%+v), but instead was (%+v)" , e .fixtureName , e .expectedAcceptedCurrencies , acceptedCurrencies )
164
+ t .Errorf ("expected to have acceptedCurrencies response (%+v), but instead was (%+v)" , e .expectedAcceptedCurrencies , acceptedCurrencies )
165
+ }
166
+ if actual := l .GetCryptoDivisibility (); actual != e .expectedCryptoDivisibility {
167
+ t .Errorf ("expected to have divisibility (%d), but was (%d)" , e .expectedCryptoDivisibility , actual )
168
+ }
169
+ if actual := l .GetCryptoCurrencyCode (); actual != e .expectedCryptoCurrencyCode {
170
+ t .Errorf ("expected to have currency code (%s), but was (%s)" , e .expectedCryptoCurrencyCode , actual )
150
171
}
151
172
}
152
173
}
0 commit comments