Priceupdater-v0 (#23)

* First price-updater implementation

* Lint corrections

* Structs revision

* Read Write Mutex

* Review price updater and apply small changes

Co-authored-by: Toni Ramírez <toni@iden3.com>
Co-authored-by: Eduard S <eduard@iden3.io>
This commit is contained in:
arnau
2020-07-31 10:23:52 +02:00
committed by GitHub
parent 819b29d9ba
commit 2c247bf9c3
2 changed files with 176 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package priceupdater
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCon(t *testing.T) {
config := ConfigPriceUpdater{
RecommendedFee: 1,
RecommendedCreateAccountFee: 1,
TokensList: []string{"ETH", "NEC"},
APIURL: "https://api-pub.bitfinex.com/v2/",
}
pud := NewPriceUpdater(config)
err := pud.UpdatePrices()
assert.Equal(t, err, nil)
info, _ := pud.Get("ETH")
assert.NotZero(t, info.Value)
info2, _ := pud.Get("NEC")
assert.NotZero(t, info2.Value)
info3, err := pud.Get("INVENTED")
if assert.Error(t, err) {
assert.Equal(t, ErrSymbolDoesNotExistInDatabase, err)
}
assert.Equal(t, info3.Value, float64(0))
prices := pud.GetPrices()
assert.Equal(t, prices["ETH"], info)
assert.Equal(t, prices["NEC"], info2)
}