Skip to content

Commit

Permalink
get rid of some shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaytonNorthey92 committed Jul 17, 2024
1 parent 53a429c commit cfc4d54
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions service/tbc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestBlockHeadersByHeightRaw(t *testing.T) {
t.Fatal(ctx.Err())
}

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeadersByHeightRawRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeadersByHeightRawRequest{
Height: 55,
}); err != nil {
t.Fatal(err)
Expand All @@ -77,7 +77,7 @@ func TestBlockHeadersByHeightRaw(t *testing.T) {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -133,22 +133,22 @@ func TestBlockHeadersByHeight(t *testing.T) {
t.Fatal(ctx.Err())
}

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeadersByHeightRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeadersByHeightRequest{
Height: 55,
}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdBlockHeadersByHeightResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -197,22 +197,22 @@ func TestBlockHeadersByHeightDoesNotExist(t *testing.T) {
t.Fatal(ctx.Err())
}

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeadersByHeightRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeadersByHeightRequest{
Height: 550,
}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdBlockHeadersByHeightResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -254,20 +254,20 @@ func TestBlockHeaderBestRaw(t *testing.T) {
case <-ctx.Done():
t.Fatal(ctx.Err())
}
if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeaderBestRawRequest{}); err != nil {
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeaderBestRawRequest{}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdBlockHeaderBestRawResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -323,20 +323,20 @@ func TestBtcBlockHeaderBest(t *testing.T) {
t.Fatal(ctx.Err())
}

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeaderBestRequest{}); err != nil {
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BlockHeaderBestRequest{}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdBlockHeaderBestResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -493,7 +493,7 @@ func TestBalanceByAddress(t *testing.T) {
}
indexAll(ctx, t, tbcServer)

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BalanceByAddressRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.BalanceByAddressRequest{
Address: tti.address(),
}); err != nil {
t.Fatal(err)
Expand All @@ -508,7 +508,7 @@ func TestBalanceByAddress(t *testing.T) {
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 {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -716,7 +716,7 @@ func TestUtxosByAddressRaw(t *testing.T) {
}
indexAll(ctx, t, tbcServer)

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.UtxosByAddressRawRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.UtxosByAddressRawRequest{
Address: tti.address(),
Start: uint(tti.start),
Count: uint(tti.limit),
Expand All @@ -734,7 +734,7 @@ func TestUtxosByAddressRaw(t *testing.T) {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -929,7 +929,7 @@ func TestUtxosByAddress(t *testing.T) {
}
indexAll(ctx, t, tbcServer)

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.UtxosByAddressRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.UtxosByAddressRequest{
Address: tti.address(),
Start: uint(tti.start),
Count: uint(tti.limit),
Expand All @@ -947,7 +947,7 @@ func TestUtxosByAddress(t *testing.T) {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -1017,22 +1017,22 @@ func TestTxByIdRaw(t *testing.T) {

slices.Reverse(txIdBytes) // convert to natural order

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRawRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRawRequest{
TxId: txIdBytes,
}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdTxByIdRawResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -1106,22 +1106,22 @@ func TestTxByIdRawInvalid(t *testing.T) {

slices.Reverse(txIdBytes) // convert to natural order

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRawRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRawRequest{
TxId: txIdBytes,
}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdTxByIdRawResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -1202,22 +1202,22 @@ func TestTxByIdRawNotFound(t *testing.T) {

slices.Reverse(txIdBytes) // convert to natural order

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRawRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRawRequest{
TxId: txIdBytes,
}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdTxByIdRawResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -1281,22 +1281,22 @@ func TestTxById(t *testing.T) {
t.Fatal(err)
}

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRequest{
TxId: txIdBytes,
}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdTxByIdResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -1365,22 +1365,22 @@ func TestTxByIdInvalid(t *testing.T) {

txIdBytes[0]++

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRequest{
TxId: txIdBytes,
}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdTxByIdResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -1460,22 +1460,22 @@ func TestTxByIdNotFound(t *testing.T) {

txIdBytes = append(txIdBytes, 8)

if err := tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRequest{
if err = tbcapi.Write(ctx, tws.conn, "someid", tbcapi.TxByIdRequest{
TxId: txIdBytes,
}); err != nil {
t.Fatal(err)
}

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

if v.Header.Command != tbcapi.CmdTxByIdResponse {
t.Fatalf("received unexpected command: %s", v.Header.Command)
}

if err := json.Unmarshal(v.Payload, &response); err != nil {
if err = json.Unmarshal(v.Payload, &response); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -1510,11 +1510,11 @@ func indexAll(ctx context.Context, t *testing.T, tbcServer *Server) {

hash := bh.BlockHash()

if err := tbcServer.TxIndexer(ctx, &hash); err != nil {
if err = tbcServer.TxIndexer(ctx, &hash); err != nil {
t.Fatal(err)
}

if err := tbcServer.UtxoIndexer(ctx, &hash); err != nil {
if err = tbcServer.UtxoIndexer(ctx, &hash); err != nil {
t.Fatal(err)
}
}

0 comments on commit cfc4d54

Please sign in to comment.