mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-08 23:16:54 +00:00
Link up websocket handler to routes after refactor and various improvements
This commit is contained in:
@@ -108,10 +108,12 @@ func GetCryptoIDAddress(address string, coinType string) (float64, error) {
|
||||
}
|
||||
|
||||
// GetAddressBalance acceses the portfolio base and returns the balance by passed
|
||||
// in address
|
||||
func (p *Base) GetAddressBalance(address string) (float64, bool) {
|
||||
// in address, coin type and description
|
||||
func (p *Base) GetAddressBalance(address, coinType, description string) (float64, bool) {
|
||||
for x := range p.Addresses {
|
||||
if p.Addresses[x].Address == address {
|
||||
if p.Addresses[x].Address == address &&
|
||||
p.Addresses[x].Description == description &&
|
||||
p.Addresses[x].CoinType == coinType {
|
||||
return p.Addresses[x].Balance, true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,12 +49,12 @@ func TestGetAddressBalance(t *testing.T) {
|
||||
portfolio := Base{}
|
||||
portfolio.AddAddress(ltcAddress, ltc, description, balance)
|
||||
|
||||
addBalance, _ := portfolio.GetAddressBalance("LdP8Qox1VAhCzLJNqrr74YovaWYyNBUWvL")
|
||||
addBalance, _ := portfolio.GetAddressBalance("LdP8Qox1VAhCzLJNqrr74YovaWYyNBUWvL", ltc, description)
|
||||
if addBalance != balance {
|
||||
t.Error("Test Failed - Portfolio GetAddressBalance() Error: Incorrect value")
|
||||
}
|
||||
|
||||
addBalance, found := portfolio.GetAddressBalance("WigWham")
|
||||
addBalance, found := portfolio.GetAddressBalance("WigWham", ltc, description)
|
||||
if addBalance != 0 {
|
||||
t.Error("Test Failed - Portfolio GetAddressBalance() Error: Incorrect value")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user