-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multi: add more bitcoind versions to the
BackendVersion
This commit adds bitcoind version 22.0 and 25.0 to our `BackendVersion` set to handle the `testmempoolaccept` RPC calls. A unit test is added to make sure the parser works as expected.
- Loading branch information
1 parent
511078b
commit bbfa799
Showing
7 changed files
with
131 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package rpcclient | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestParseBitcoindVersion checks that the correct version from bitcoind's | ||
// `getnetworkinfo` RPC call is parsed. | ||
func TestParseBitcoindVersion(t *testing.T) { | ||
t.Parallel() | ||
|
||
testCases := []struct { | ||
name string | ||
rpcVersion string | ||
parsedVersion BackendVersion | ||
}{ | ||
{ | ||
name: "parse version 0.19 and below", | ||
rpcVersion: "/Satoshi:0.18.0/", | ||
parsedVersion: BitcoindPre19, | ||
}, | ||
{ | ||
name: "parse version 0.19", | ||
rpcVersion: "/Satoshi:0.19.0/", | ||
parsedVersion: BitcoindPre22, | ||
}, | ||
{ | ||
name: "parse version 0.19 - 22.0", | ||
rpcVersion: "/Satoshi:0.20.1/", | ||
parsedVersion: BitcoindPre22, | ||
}, | ||
{ | ||
name: "parse version 22.0", | ||
rpcVersion: "/Satoshi:22.0.0/", | ||
parsedVersion: BitcoindPre25, | ||
}, | ||
{ | ||
name: "parse version 22.0 - 25.0", | ||
rpcVersion: "/Satoshi:23.0.0/", | ||
parsedVersion: BitcoindPre25, | ||
}, | ||
{ | ||
name: "parse version 25.0", | ||
rpcVersion: "/Satoshi:25.0.0/", | ||
parsedVersion: BitcoindPost25, | ||
}, | ||
{ | ||
name: "parse version 25.0 and above", | ||
rpcVersion: "/Satoshi:26.0.0/", | ||
parsedVersion: BitcoindPost25, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
|
||
t.Run(tc.name, func(t *testing.T) { | ||
version := parseBitcoindVersion(tc.rpcVersion) | ||
require.Equal(t, tc.parsedVersion, version) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters