mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* currency: Add method to derive pair * currency: Add method to lower entire charset but used the slice copy and returned that. This will change the original, just gotta see if this is an issue, but the slice usually goes out of scope anyway. * currency/pairs: add filter method * currency: add function to derive select currencies from currency pairs * currency/engine: slight adjustments * currency: fix linter issue also shift burden of proof to caller instead of repair, more performant. * currency: more linter * pairs: optimize; reduce allocs/op and B/op * currency: Add in function 'NewPairsFromString' for testing purposes * currency: don't suppress error * currency: stop panic on empty currency code * currency: Add helper method to match currencies between exchanges * currency: fixed my bad spelling * currency: Implement stable coin checks, refactored base code methods, optimized upper and lower case strings for currency code/pairs * currency: add pairs method to derive stable coins from internal list. * Currency: Cleanup, fix tests. * engine/exchanges/currency: fix whoops * Currency: force govet no copy on Item datatype * Currency: fix naughty linter issues * exchange: revert change * currency/config: fix config upgrade mistake * currency: re-implement currency sub-systems * *RetrieveConfigCurrencyPairs removed *CheckCurrencyConfigValues to only provide warnings, add additional support when, disable when support is lost or not available and set default values. *Drop Cryptocurrencies from configuration as this is not needed. *Drop REST Poll delay field as this was unused. *Update default values for currencyFileUpdateDuration & foreignExchangeUpdateDuration. *Allow Role to be marshalled for file type. *Refactor RunUpdater to verify and check config values and set default running foreign exchange provider. * currency: cleanup * currency: change match -> equal for comparison which is more of a standard and little easier to find * currency: address nits * currency: fix whoops * currency: Add some more pairs methods * currency: linter issues * currency: RM unused field * currency: rm verbose * currency: fix word * currency: gocritic * currency: fix another whoopsie * example_config: default to show log system name * Currency: Force all support packages to use Equal method for comparison as there is a small comparison bug when checking upper and lower casing, this has a more of a pronounced impact between exchanges and client instances of currency generation * currency: fix log name * ordermanager: fix potential panic * currency: small optim. * engine: display correct bool and force shutdown * currency: add function and fix regression * Change ConvertCurrency -> ConvertFiat to be more precise * ADD GetForeignExchangeRate to get specific exchange rate for fiat pair * Fix currency display and formatting regression and tied in with config.Currency fields * engine: fix tests * currency: return the amount when no conversion needs to take place * currency: reduce method name * currency: Address nits glorious nits * currency: fix linter * currency: addr nits * currency: check underlying role in test * gct: change to EMPTYCODE and EMPTYPAIR across codebase * currency: fix nits * currency: this fixes test race but this issue has not been resolved. Please see: https://trello.com/c/54eizOIo/143-currency-package-upgrades * currency: Add temp dir for testing * Update engine/engine.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * documentation: update and regen * currency: Address niterinos * currency: Add test case for config upgrade when falling over to exchange rate host as default from exchangeRates provider * currency: addr nits * currency: fix whoops Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
594 lines
14 KiB
Go
594 lines
14 KiB
Go
package currency
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestRoleString(t *testing.T) {
|
|
if Unset.String() != UnsetRoleString {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
UnsetRoleString,
|
|
Unset)
|
|
}
|
|
|
|
if Fiat.String() != FiatCurrencyString {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
FiatCurrencyString,
|
|
Fiat)
|
|
}
|
|
|
|
if Cryptocurrency.String() != CryptocurrencyString {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
CryptocurrencyString,
|
|
Cryptocurrency)
|
|
}
|
|
|
|
if Token.String() != TokenString {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
TokenString,
|
|
Token)
|
|
}
|
|
|
|
if Contract.String() != ContractString {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
ContractString,
|
|
Contract)
|
|
}
|
|
|
|
var random Role = 1 << 7
|
|
|
|
if random.String() != UnsetRoleString {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
"UNKNOWN",
|
|
random)
|
|
}
|
|
}
|
|
|
|
func TestRoleMarshalJSON(t *testing.T) {
|
|
d, err := json.Marshal(Fiat)
|
|
if err != nil {
|
|
t.Error("Role MarshalJSON() error", err)
|
|
}
|
|
|
|
if expected := `"fiatcurrency"`; string(d) != expected {
|
|
t.Errorf("Role MarshalJSON() error expected %s but received %s",
|
|
expected,
|
|
string(d))
|
|
}
|
|
}
|
|
|
|
// TestRoleUnmarshalJSON logic test
|
|
func TestRoleUnmarshalJSON(t *testing.T) {
|
|
type AllTheRoles struct {
|
|
RoleOne Role `json:"RoleOne"`
|
|
RoleTwo Role `json:"RoleTwo"`
|
|
RoleThree Role `json:"RoleThree"`
|
|
RoleFour Role `json:"RoleFour"`
|
|
RoleFive Role `json:"RoleFive"`
|
|
RoleSix Role `json:"RoleSix"`
|
|
RoleUnknown Role `json:"RoleUnknown"`
|
|
}
|
|
|
|
var outgoing = AllTheRoles{
|
|
RoleOne: Unset,
|
|
RoleTwo: Cryptocurrency,
|
|
RoleThree: Fiat,
|
|
RoleFour: Token,
|
|
RoleFive: Contract,
|
|
RoleSix: Stable,
|
|
}
|
|
|
|
e, err := json.Marshal(1337)
|
|
if err != nil {
|
|
t.Fatal("Role UnmarshalJSON() error", err)
|
|
}
|
|
|
|
var incoming AllTheRoles
|
|
err = json.Unmarshal(e, &incoming)
|
|
if err == nil {
|
|
t.Fatal("Role UnmarshalJSON() Expected error")
|
|
}
|
|
|
|
e, err = json.Marshal(outgoing)
|
|
if err != nil {
|
|
t.Fatal("Role UnmarshalJSON() error", err)
|
|
}
|
|
|
|
err = json.Unmarshal(e, &incoming)
|
|
if err != nil {
|
|
t.Fatal("Role UnmarshalJSON() error", err)
|
|
}
|
|
|
|
if incoming.RoleOne != Unset {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
Unset,
|
|
incoming.RoleOne)
|
|
}
|
|
|
|
if incoming.RoleTwo != Cryptocurrency {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
Cryptocurrency,
|
|
incoming.RoleTwo)
|
|
}
|
|
|
|
if incoming.RoleThree != Fiat {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
Fiat,
|
|
incoming.RoleThree)
|
|
}
|
|
|
|
if incoming.RoleFour != Token {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
Token,
|
|
incoming.RoleFour)
|
|
}
|
|
|
|
if incoming.RoleFive != Contract {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
Contract,
|
|
incoming.RoleFive)
|
|
}
|
|
|
|
if incoming.RoleUnknown != Unset {
|
|
t.Errorf("Role String() error expected %s but received %s",
|
|
incoming.RoleFive,
|
|
incoming.RoleUnknown)
|
|
}
|
|
var unhandled Role
|
|
err = unhandled.UnmarshalJSON([]byte("\"ThisIsntReal\""))
|
|
if err == nil {
|
|
t.Error("Expected unmarshall error")
|
|
}
|
|
|
|
err = unhandled.UnmarshalJSON([]byte(`1336`))
|
|
if err == nil {
|
|
t.Error("Expected unmarshall error")
|
|
}
|
|
}
|
|
|
|
func (b *BaseCodes) assertRole(t *testing.T, c Code, r Role) {
|
|
t.Helper()
|
|
b.mtx.Lock()
|
|
defer b.mtx.Unlock()
|
|
for x := range b.Items {
|
|
if b.Items[x] != c.Item {
|
|
continue
|
|
}
|
|
if b.Items[x].Role != r {
|
|
t.Fatal("unexpected role")
|
|
}
|
|
return
|
|
}
|
|
t.Fatal("code pointer not found")
|
|
}
|
|
|
|
func TestBaseCode(t *testing.T) {
|
|
var main BaseCodes
|
|
if main.HasData() {
|
|
t.Errorf("BaseCode HasData() error expected false but received %v",
|
|
main.HasData())
|
|
}
|
|
|
|
catsUnset := main.Register("CATS", Unset)
|
|
main.assertRole(t, catsUnset, Unset)
|
|
if !main.HasData() {
|
|
t.Errorf("BaseCode HasData() error expected true but received %v",
|
|
main.HasData())
|
|
}
|
|
|
|
// Changes unset to fiat
|
|
catsFiat := main.Register("CATS", Fiat)
|
|
main.assertRole(t, catsUnset, Fiat)
|
|
|
|
// Register as unset, will return first match.
|
|
otherFiatCat := main.Register("CATS", Unset)
|
|
main.assertRole(t, otherFiatCat, Fiat)
|
|
if !otherFiatCat.Equal(catsFiat) {
|
|
t.Errorf("BaseCode Match() error expected true but received %v",
|
|
false)
|
|
}
|
|
|
|
// Register as fiat, will return fiat match.
|
|
thatOtherFiatCat := main.Register("CATS", Fiat)
|
|
main.assertRole(t, otherFiatCat, Fiat)
|
|
if !thatOtherFiatCat.Equal(catsFiat) {
|
|
t.Errorf("BaseCode Match() error expected true but received %v",
|
|
false)
|
|
}
|
|
|
|
// Register as stable, will return a different currency with the same
|
|
// currency code.
|
|
superStableCatNoShakes := main.Register("CATS", Stable)
|
|
main.assertRole(t, superStableCatNoShakes, Stable)
|
|
if superStableCatNoShakes.Equal(catsFiat) {
|
|
t.Errorf("BaseCode Match() error expected true but received %v",
|
|
true)
|
|
}
|
|
|
|
// Due to the role being unset originally, this will be set to Fiat when
|
|
// explicitly set.
|
|
if !catsUnset.Equal(catsFiat) {
|
|
t.Fatal("both should be the same")
|
|
}
|
|
|
|
if main.Register("DOGS", Unset).Equal(catsUnset) {
|
|
t.Errorf("BaseCode Match() error expected false but received %v",
|
|
true)
|
|
}
|
|
|
|
loadedCurrencies := main.GetCurrencies()
|
|
|
|
if loadedCurrencies.Contains(main.Register("OWLS", Unset)) {
|
|
t.Errorf("BaseCode Contains() error expected false but received %v",
|
|
true)
|
|
}
|
|
|
|
if !loadedCurrencies.Contains(catsFiat) {
|
|
t.Errorf("BaseCode Contains() error expected true but received %v",
|
|
false)
|
|
}
|
|
|
|
main.Register("XBTUSD", Unset)
|
|
|
|
err := main.UpdateCurrency("Bitcoin Perpetual",
|
|
"XBTUSD",
|
|
"",
|
|
0,
|
|
Contract)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
main.Register("BTC", Unset)
|
|
err = main.UpdateCurrency("Bitcoin", "BTC", "", 1337, Unset)
|
|
if !errors.Is(err, errRoleUnset) {
|
|
t.Fatalf("received: '%v' but expected: '%v'", err, errRoleUnset)
|
|
}
|
|
|
|
err = main.UpdateCurrency("Bitcoin", "BTC", "", 1337, Cryptocurrency)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
aud := main.Register("AUD", Unset)
|
|
err = main.UpdateCurrency("Unreal Dollar", "AUD", "", 1111, Fiat)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if aud.Item.FullName != "Unreal Dollar" {
|
|
t.Error("Expected fullname to update for AUD")
|
|
}
|
|
|
|
err = main.UpdateCurrency("Australian Dollar", "AUD", "", 1336, Fiat)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
aud.Item.Role = Unset
|
|
err = main.UpdateCurrency("Australian Dollar", "AUD", "", 1336, Fiat)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if aud.Item.Role != Fiat {
|
|
t.Error("Expected role to change to Fiat")
|
|
}
|
|
|
|
main.Register("PPT", Unset)
|
|
err = main.UpdateCurrency("Populous", "PPT", "ETH", 1335, Token)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
contract := main.Register("XBTUSD", Unset)
|
|
|
|
if contract.IsFiatCurrency() {
|
|
t.Errorf("BaseCode IsFiatCurrency() error expected false but received %v",
|
|
true)
|
|
}
|
|
|
|
if contract.IsCryptocurrency() {
|
|
t.Errorf("BaseCode IsCryptocurrency() error expected false but received %v",
|
|
true)
|
|
}
|
|
|
|
err = main.LoadItem(nil)
|
|
if !errors.Is(err, errItemIsNil) {
|
|
t.Fatalf("received: '%v' but expected: '%v'", err, errItemIsNil)
|
|
}
|
|
|
|
err = main.LoadItem(&Item{})
|
|
if !errors.Is(err, errItemIsEmpty) {
|
|
t.Fatalf("received: '%v' but expected: '%v'", err, errItemIsEmpty)
|
|
}
|
|
|
|
err = main.LoadItem(&Item{
|
|
ID: 0,
|
|
FullName: "Cardano",
|
|
Role: Cryptocurrency,
|
|
Symbol: "ADA",
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
err = main.LoadItem(&Item{
|
|
ID: 0,
|
|
FullName: "Cardano",
|
|
Role: Cryptocurrency,
|
|
Symbol: "ADA",
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
full, err := main.GetFullCurrencyData()
|
|
if err != nil {
|
|
t.Error("BaseCode GetFullCurrencyData error", err)
|
|
}
|
|
|
|
if len(full.Contracts) != 1 {
|
|
t.Errorf("BaseCode GetFullCurrencyData() error expected 1 but received %v",
|
|
len(full.Contracts))
|
|
}
|
|
|
|
if len(full.Cryptocurrency) != 2 {
|
|
t.Errorf("BaseCode GetFullCurrencyData() error expected 1 but received %v",
|
|
len(full.Cryptocurrency))
|
|
}
|
|
|
|
if len(full.FiatCurrency) != 2 {
|
|
t.Errorf("BaseCode GetFullCurrencyData() error expected 1 but received %v",
|
|
len(full.FiatCurrency))
|
|
}
|
|
|
|
if len(full.Token) != 1 {
|
|
t.Errorf("BaseCode GetFullCurrencyData() error expected 1 but received %v",
|
|
len(full.Token))
|
|
}
|
|
|
|
if len(full.UnsetCurrency) != 2 {
|
|
t.Errorf("BaseCode GetFullCurrencyData() error expected 3 but received %v",
|
|
len(full.UnsetCurrency))
|
|
}
|
|
|
|
if full.LastMainUpdate.(int64) != -62135596800 {
|
|
t.Errorf("BaseCode GetFullCurrencyData() error expected -62135596800 but received %d",
|
|
full.LastMainUpdate)
|
|
}
|
|
|
|
err = main.LoadItem(&Item{
|
|
ID: 0,
|
|
FullName: "Cardano",
|
|
Role: Role(99),
|
|
Symbol: "ADA",
|
|
})
|
|
if err != nil {
|
|
t.Error("BaseCode LoadItem() error", err)
|
|
}
|
|
_, err = main.GetFullCurrencyData()
|
|
if err == nil {
|
|
t.Error("Expected 'Role undefined'")
|
|
}
|
|
|
|
main.Items[0].FullName = "Hello"
|
|
err = main.UpdateCurrency("MEWOW", "CATS", "", 1338, Fiat)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if main.Items[0].FullName != "MEWOW" {
|
|
t.Error("Fullname not updated")
|
|
}
|
|
err = main.UpdateCurrency("MEWOW", "CATS", "", 1338, Fiat)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
err = main.UpdateCurrency("WOWCATS", "CATS", "", 3, Fiat)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// Creates a new item under a different currency role
|
|
if main.Items[0].ID != 3 {
|
|
t.Error("ID not updated")
|
|
}
|
|
|
|
main.Items[0].Role = Unset
|
|
err = main.UpdateCurrency("MEWOW", "CATS", "", 1338, Cryptocurrency)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if main.Items[0].ID != 1338 {
|
|
t.Error("ID not updated")
|
|
}
|
|
}
|
|
|
|
func TestCodeString(t *testing.T) {
|
|
if cc, expected := NewCode("TEST"), "TEST"; cc.String() != expected {
|
|
t.Errorf("Currency Code String() error expected %s but received %s",
|
|
expected, cc)
|
|
}
|
|
}
|
|
|
|
func TestCodeLower(t *testing.T) {
|
|
if cc, expected := NewCode("TEST"), "test"; cc.Lower().String() != expected {
|
|
t.Errorf("Currency Code Lower() error expected %s but received %s",
|
|
expected,
|
|
cc.Lower())
|
|
}
|
|
}
|
|
|
|
func TestCodeUpper(t *testing.T) {
|
|
if cc, expected := NewCode("test"), "TEST"; cc.Upper().String() != expected {
|
|
t.Errorf("Currency Code Upper() error expected %s but received %s",
|
|
expected,
|
|
cc.Upper())
|
|
}
|
|
}
|
|
|
|
func TestCodeUnmarshalJSON(t *testing.T) {
|
|
var unmarshalHere Code
|
|
expected := "BRO"
|
|
encoded, err := json.Marshal(expected)
|
|
if err != nil {
|
|
t.Fatal("Currency Code UnmarshalJSON error", err)
|
|
}
|
|
|
|
err = json.Unmarshal(encoded, &unmarshalHere)
|
|
if err != nil {
|
|
t.Fatal("Currency Code UnmarshalJSON error", err)
|
|
}
|
|
|
|
err = json.Unmarshal(encoded, &unmarshalHere)
|
|
if err != nil {
|
|
t.Fatal("Currency Code UnmarshalJSON error", err)
|
|
}
|
|
|
|
if unmarshalHere.String() != expected {
|
|
t.Errorf("Currency Code Upper() error expected %s but received %s",
|
|
expected,
|
|
unmarshalHere)
|
|
}
|
|
|
|
encoded, err = json.Marshal(1336) // :'(
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
err = json.Unmarshal(encoded, &unmarshalHere)
|
|
if err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
}
|
|
|
|
func TestCodeMarshalJSON(t *testing.T) {
|
|
quickstruct := struct {
|
|
Codey Code `json:"sweetCodes"`
|
|
}{
|
|
Codey: NewCode("BRO"),
|
|
}
|
|
|
|
expectedJSON := `{"sweetCodes":"BRO"}`
|
|
|
|
encoded, err := json.Marshal(quickstruct)
|
|
if err != nil {
|
|
t.Fatal("Currency Code UnmarshalJSON error", err)
|
|
}
|
|
|
|
if string(encoded) != expectedJSON {
|
|
t.Errorf("Currency Code Upper() error expected %s but received %s",
|
|
expectedJSON,
|
|
string(encoded))
|
|
}
|
|
|
|
quickstruct = struct {
|
|
Codey Code `json:"sweetCodes"`
|
|
}{
|
|
Codey: EMPTYCODE, // nil code
|
|
}
|
|
|
|
encoded, err = json.Marshal(quickstruct)
|
|
if err != nil {
|
|
t.Fatal("Currency Code UnmarshalJSON error", err)
|
|
}
|
|
|
|
newExpectedJSON := `{"sweetCodes":""}`
|
|
if string(encoded) != newExpectedJSON {
|
|
t.Errorf("Currency Code Upper() error expected %s but received %s",
|
|
newExpectedJSON, string(encoded))
|
|
}
|
|
}
|
|
|
|
func TestIsFiatCurrency(t *testing.T) {
|
|
if EMPTYCODE.IsFiatCurrency() {
|
|
t.Errorf("TestIsFiatCurrency cannot match currency, %s.",
|
|
EMPTYCODE)
|
|
}
|
|
if !USD.IsFiatCurrency() {
|
|
t.Errorf(
|
|
"TestIsFiatCurrency cannot match currency, %s.", USD)
|
|
}
|
|
if !CNY.IsFiatCurrency() {
|
|
t.Errorf(
|
|
"TestIsFiatCurrency cannot match currency, %s.", CNY)
|
|
}
|
|
if LINO.IsFiatCurrency() {
|
|
t.Errorf(
|
|
"TestIsFiatCurrency cannot match currency, %s.", LINO,
|
|
)
|
|
}
|
|
if USDT.IsFiatCurrency() {
|
|
t.Errorf(
|
|
"TestIsFiatCurrency cannot match currency, %s.", USD)
|
|
}
|
|
if DAI.IsFiatCurrency() {
|
|
t.Errorf(
|
|
"TestIsFiatCurrency cannot match currency, %s.", USD)
|
|
}
|
|
}
|
|
|
|
func TestIsCryptocurrency(t *testing.T) {
|
|
if EMPTYCODE.IsCryptocurrency() {
|
|
t.Errorf("TestIsCryptocurrency cannot match currency, %s.",
|
|
EMPTYCODE)
|
|
}
|
|
if !BTC.IsCryptocurrency() {
|
|
t.Errorf("TestIsCryptocurrency cannot match currency, %s.",
|
|
BTC)
|
|
}
|
|
if !LTC.IsCryptocurrency() {
|
|
t.Errorf("TestIsCryptocurrency cannot match currency, %s.",
|
|
LTC)
|
|
}
|
|
if AUD.IsCryptocurrency() {
|
|
t.Errorf("TestIsCryptocurrency cannot match currency, %s.",
|
|
AUD)
|
|
}
|
|
if !USDT.IsCryptocurrency() {
|
|
t.Errorf(
|
|
"TestIsCryptocurrency cannot match currency, %s.", USD)
|
|
}
|
|
if !DAI.IsCryptocurrency() {
|
|
t.Errorf(
|
|
"TestIsCryptocurrency cannot match currency, %s.", USD)
|
|
}
|
|
}
|
|
|
|
func TestIsStableCurrency(t *testing.T) {
|
|
if EMPTYCODE.IsStableCurrency() {
|
|
t.Errorf("TestIsStableCurrency cannot match currency, %s.", EMPTYCODE)
|
|
}
|
|
if BTC.IsStableCurrency() {
|
|
t.Errorf("TestIsStableCurrency cannot match currency, %s.", BTC)
|
|
}
|
|
if LTC.IsStableCurrency() {
|
|
t.Errorf("TestIsStableCurrency cannot match currency, %s.", LTC)
|
|
}
|
|
if AUD.IsStableCurrency() {
|
|
t.Errorf("TestIsStableCurrency cannot match currency, %s.", AUD)
|
|
}
|
|
if !USDT.IsStableCurrency() {
|
|
t.Errorf("TestIsStableCurrency cannot match currency, %s.", USDT)
|
|
}
|
|
if !DAI.IsStableCurrency() {
|
|
t.Errorf("TestIsStableCurrency cannot match currency, %s.", DAI)
|
|
}
|
|
}
|
|
|
|
func TestItemString(t *testing.T) {
|
|
newItem := Item{
|
|
ID: 1337,
|
|
FullName: "Hello,World",
|
|
Symbol: "HWORLD",
|
|
AssocChain: "Silly",
|
|
}
|
|
|
|
if expected := "HWORLD"; newItem.String() != expected {
|
|
t.Errorf("Currency String() error expected '%s' but received '%s'",
|
|
expected,
|
|
&newItem)
|
|
}
|
|
}
|