mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 19:36:44 +01:00
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:
40
priceupdater/priceupdater_test.go
Normal file
40
priceupdater/priceupdater_test.go
Normal 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)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user