Skip to content

Commit

Permalink
more code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaytonNorthey92 committed Jul 17, 2024
1 parent cfc4d54 commit 0ac0758
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions service/tbc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,41 +500,40 @@ func TestBalanceByAddress(t *testing.T) {
}

var v protocol.Message
err = wsjson.Read(ctx, c, &v)
if err != nil {
if err = wsjson.Read(ctx, c, &v); err != nil {
t.Fatal(err)
}

if v.Header.Command != tbcapi.CmdBalanceByAddressResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
} else {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}
}

var pricePerBlock uint64 = 50 * 100000000
var blocks uint64 = 4
var expectedBalance uint64 = 0
if !tti.doNotGenerate {
expectedBalance = pricePerBlock * blocks
}
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

expected := tbcapi.BalanceByAddressResponse{
Balance: expectedBalance,
Error: nil,
}
if diff := deep.Equal(expected, response); len(diff) > 0 {
if response.Error != nil {
t.Error(response.Error.Message)
}
t.Logf("unexpected diff: %s", diff)

// there is a chance we just haven't finished indexing
// the blocks and txs, retry until timeout
continue
} else {
break
var pricePerBlock uint64 = 50 * 100000000
var blocks uint64 = 4
var expectedBalance uint64 = 0
if !tti.doNotGenerate {
expectedBalance = pricePerBlock * blocks
}

expected := tbcapi.BalanceByAddressResponse{
Balance: expectedBalance,
Error: nil,
}
if diff := deep.Equal(expected, response); len(diff) > 0 {
if response.Error != nil {
t.Error(response.Error.Message)
}
t.Logf("unexpected diff: %s", diff)

// there is a chance we just haven't finished indexing
// the blocks and txs, retry until timeout
continue
} else {
break
}
}
})
Expand Down Expand Up @@ -725,8 +724,7 @@ func TestUtxosByAddressRaw(t *testing.T) {
}

var v protocol.Message
err = wsjson.Read(ctx, c, &v)
if err != nil {
if err = wsjson.Read(ctx, c, &v); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -938,8 +936,7 @@ func TestUtxosByAddress(t *testing.T) {
}

var v protocol.Message
err = wsjson.Read(ctx, c, &v)
if err != nil {
if err = wsjson.Read(ctx, c, &v); err != nil {
t.Fatal(err)
}

Expand Down

0 comments on commit 0ac0758

Please sign in to comment.