Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
feat(bytom2.0 net): fix unit test and other (#1847)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksoom authored Mar 31, 2021
1 parent 4179464 commit 0edeef6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
11 changes: 6 additions & 5 deletions common/bech32/bech32_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bech32

import (
"fmt"
"strings"
"testing"
)
Expand All @@ -15,11 +16,11 @@ func TestBech32(t *testing.T) {
{"abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw", true},
{"11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", true},
{"split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", true},
{"split1checkupstagehandshakeupstreamerranterredcaperred2y9e2w", false}, // invalid checksum
{"s lit1checkupstagehandshakeupstreamerranterredcaperredp8hs2p", false}, // invalid character (space) in hrp
{"spl" + string(127) + "t1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", false}, // invalid character (DEL) in hrp
{"split1cheo2y9e2w", false}, // invalid character (o) in data part
{"split1a2y9w", false}, // too short data part
{"split1checkupstagehandshakeupstreamerranterredcaperred2y9e2w", false}, // invalid checksum
{"s lit1checkupstagehandshakeupstreamerranterredcaperredp8hs2p", false}, // invalid character (space) in hrp
{"spl" + fmt.Sprint(127) + "t1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", false}, // invalid character (DEL) in hrp
{"split1cheo2y9e2w", false}, // invalid character (o) in data part
{"split1a2y9w", false}, // too short data part
{"1checkupstagehandshakeupstreamerranterredcaperred2y9e3w", false}, // empty hrp
{"11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqsqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", false}, // too long
}
Expand Down
2 changes: 1 addition & 1 deletion net/http/authn/authn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"testing"

"github.com/bytom/bytom/accesstoken"
"github.com/bytom/bytom/errors"
dbm "github.com/bytom/bytom/database/leveldb"
"github.com/bytom/bytom/errors"
)

func TestAuthenticate(t *testing.T) {
Expand Down
7 changes: 6 additions & 1 deletion net/websocket/wsnotificationmaneger.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,12 @@ out:
}

if m.status.BestHash != block.PreviousBlockHash {
log.WithFields(log.Fields{"module": logModule, "blockHeight": block.Height, "previousBlockHash": m.status.BestHash, "rcvBlockPrevHash": block.PreviousBlockHash}).Warning("The previousBlockHash of the received block is not the same as the hash of the previous block")
log.WithFields(log.Fields{
"module": logModule,
"block_height": block.Height,
"status_block_hash": m.status.BestHash.String(),
"retrive_block_PrevHash": block.PreviousBlockHash.String(),
}).Warning("The previousBlockHash of the received block is not the same as the hash of the previous block")
continue
}

Expand Down
2 changes: 1 addition & 1 deletion p2p/upnp/upnp.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func getServiceURL(rootURL string) (url, urnDomain string, err error) {
defer r.Body.Close() // nolint: errcheck

if r.StatusCode >= 400 {
err = errors.New(string(r.StatusCode))
err = errors.New(fmt.Sprint(r.StatusCode))
return
}
var root Root
Expand Down
2 changes: 1 addition & 1 deletion test/tx_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func SignInstructionFor(input *types.SpendInput, db dbm.DB, signer *signers.Sign
func CreateCoinbaseTx(controlProgram []byte, height, txsFee uint64) (*types.Tx, error) {
coinbaseValue := consensus.BlockSubsidy(height) + txsFee
builder := txbuilder.NewBuilder(time.Now())
if err := builder.AddInput(types.NewCoinbaseInput([]byte(string(height))), &txbuilder.SigningInstruction{}); err != nil {
if err := builder.AddInput(types.NewCoinbaseInput([]byte(fmt.Sprint(height))), &txbuilder.SigningInstruction{}); err != nil {
return nil, err
}
if err := builder.AddOutput(types.NewTxOutput(*consensus.BTMAssetID, coinbaseValue, controlProgram)); err != nil {
Expand Down
15 changes: 2 additions & 13 deletions wallet/utxo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

"github.com/bytom/bytom/account"
"github.com/bytom/bytom/consensus"
dbm "github.com/bytom/bytom/database/leveldb"
"github.com/bytom/bytom/protocol/bc"
"github.com/bytom/bytom/protocol/bc/types"
"github.com/bytom/bytom/testutil"
dbm "github.com/bytom/bytom/database/leveldb"
)

func TestGetAccountUtxos(t *testing.T) {
Expand Down Expand Up @@ -250,11 +250,6 @@ func TestFilterAccountUtxo(t *testing.T) {
ControlProgramIndex: 53,
Change: true,
},
&account.UTXO{
ControlProgram: []byte{0x91},
AssetID: bc.AssetID{V0: 1},
Amount: 4,
},
},
},
{
Expand All @@ -271,13 +266,7 @@ func TestFilterAccountUtxo(t *testing.T) {
Amount: 3,
},
},
wantUtxos: []*account.UTXO{
&account.UTXO{
ControlProgram: []byte{0x91},
AssetID: bc.AssetID{V0: 1},
Amount: 3,
},
},
wantUtxos: []*account.UTXO{},
},
{
dbPrograms: map[string]*account.CtrlProgram{
Expand Down

0 comments on commit 0edeef6

Please sign in to comment.