Add test for historical balances
This commit is contained in:
parent
a45bfe47c2
commit
fa7b34f90d
1 changed files with 46 additions and 1 deletions
|
@ -41,7 +41,7 @@ func TestAccountBalance_Offline(t *testing.T) {
|
||||||
mockIndexer.AssertExpectations(t)
|
mockIndexer.AssertExpectations(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccountBalance_Online(t *testing.T) {
|
func TestAccountBalance_Online_Current(t *testing.T) {
|
||||||
cfg := &configuration.Configuration{
|
cfg := &configuration.Configuration{
|
||||||
Mode: configuration.Online,
|
Mode: configuration.Online,
|
||||||
Currency: bitcoin.MainnetCurrency,
|
Currency: bitcoin.MainnetCurrency,
|
||||||
|
@ -104,3 +104,48 @@ func TestAccountBalance_Online(t *testing.T) {
|
||||||
|
|
||||||
mockIndexer.AssertExpectations(t)
|
mockIndexer.AssertExpectations(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccountBalance_Online_Historical(t *testing.T) {
|
||||||
|
cfg := &configuration.Configuration{
|
||||||
|
Mode: configuration.Online,
|
||||||
|
Currency: bitcoin.MainnetCurrency,
|
||||||
|
}
|
||||||
|
mockIndexer := &mocks.Indexer{}
|
||||||
|
servicer := NewAccountAPIService(cfg, mockIndexer)
|
||||||
|
ctx := context.Background()
|
||||||
|
account := &types.AccountIdentifier{
|
||||||
|
Address: "hello",
|
||||||
|
}
|
||||||
|
block := &types.BlockIdentifier{
|
||||||
|
Index: 1000,
|
||||||
|
Hash: "block 1000",
|
||||||
|
}
|
||||||
|
partialBlock := &types.PartialBlockIdentifier{
|
||||||
|
Index: &block.Index,
|
||||||
|
}
|
||||||
|
amount := &types.Amount{
|
||||||
|
Value: "25",
|
||||||
|
Currency: bitcoin.MainnetCurrency,
|
||||||
|
}
|
||||||
|
|
||||||
|
mockIndexer.On(
|
||||||
|
"GetBalance",
|
||||||
|
ctx,
|
||||||
|
account,
|
||||||
|
bitcoin.MainnetCurrency,
|
||||||
|
partialBlock,
|
||||||
|
).Return(amount, block, nil).Once()
|
||||||
|
bal, err := servicer.AccountBalance(ctx, &types.AccountBalanceRequest{
|
||||||
|
AccountIdentifier: account,
|
||||||
|
BlockIdentifier: partialBlock,
|
||||||
|
})
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, &types.AccountBalanceResponse{
|
||||||
|
BlockIdentifier: block,
|
||||||
|
Balances: []*types.Amount{
|
||||||
|
amount,
|
||||||
|
},
|
||||||
|
}, bal)
|
||||||
|
|
||||||
|
mockIndexer.AssertExpectations(t)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue