trezor / blockbook

:blue_book: Trezor address/account balance backend
https://trezor.io
GNU Affero General Public License v3.0
671 stars 654 forks source link

add tests for bitcoin testnet4 #1147

Closed grdddj closed 4 days ago

grdddj commented 1 month ago

Integrating the code related to this issue - https://github.com/trezor/blockbook/issues/1130

The credit for tests goes to @wakiyamap

wakiyamap commented 3 weeks ago
--- a/bchain/coins/btc/bitcoinparser.go
+++ b/bchain/coins/btc/bitcoinparser.go
@@ -50,7 +50,7 @@ func GetChainParams(chain string) *chaincfg.Params {
        switch chain {
        case "test":
                return &chaincfg.TestNet3Params
-       case "test4":
+       case "testnet4":

+++ b/bchain/coins/btc/bitcoinparser_test.go
@@ -682,7 +682,7 @@ func TestPackTx(t *testing.T) {
                                tx:        testTx4,
                                height:    41657,
                                blockTime: 1724927392,
-                               parser:    NewBitcoinParser(GetChainParams("test4"), &Configuration{}),
+                               parser:    NewBitcoinParser(GetChainParams("testnet4"), &Configuration{}),
                        },
                        want:    testTxPacked4,
                        wantErr: false,
@@ -749,7 +749,7 @@ func TestUnpackTx(t *testing.T) {
                        name: "testnet4-1",
                        args: args{
                                packedTx: testTxPacked4,
-                               parser:   NewBitcoinParser(GetChainParams("test4"), &Configuration{}),
+                               parser:   NewBitcoinParser(GetChainParams("testnet4"), &Configuration{}),
                        },
                        want:    &testTx4,
                        want1:   41657,

When getblockchaininfo was testnet4, it returned testnet4 instead of test4. Therefore, this code will run with mainnet parameters. https://github.com/wakiyamap/blockbook/commits/testnet4-bitcoin/ https://testnet4-explorer.wakiyamap.dev/

It's fine to leave testnet3 as test. https://tbtc1.trezor.io/