-
Notifications
You must be signed in to change notification settings - Fork 3
fix: integration tests, continued dashificiation #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v0.40-dev
Are you sure you want to change the base?
Changes from all commits
fd2f32b
a431835
dd10029
fd56746
674590c
21becec
4a66bc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,46 @@ | ||
#!/bin/sh | ||
|
||
TESTDIR=/tmp/rust_bitcoincore_rpc_test | ||
set -e | ||
|
||
rm -rf ${TESTDIR} | ||
mkdir -p ${TESTDIR}/1 ${TESTDIR}/2 | ||
TESTDIR=/tmp/rust_dashcore_rpc_test | ||
|
||
# To kill any remaining open bitcoind. | ||
killall -9 bitcoind | ||
rm -rf "${TESTDIR}" | ||
mkdir -p "${TESTDIR}/dash" | ||
|
||
bitcoind -regtest \ | ||
-datadir=${TESTDIR}/1 \ | ||
-port=12348 \ | ||
-server=0 \ | ||
-printtoconsole=0 & | ||
PID1=$! | ||
# Kill any remaining dashd to avoid port conflicts | ||
if command -v killall >/dev/null 2>&1; then | ||
killall -9 dashd 2>/dev/null || true | ||
fi | ||
|
||
# Make sure it's listening on its p2p port. | ||
sleep 3 | ||
# Start Dash Core on regtest using standard Dash RPC port 19898 | ||
dashd -regtest \ | ||
-datadir="${TESTDIR}/dash" \ | ||
-rpcport=19898 \ | ||
-server=1 \ | ||
-txindex=1 \ | ||
-printtoconsole=0 & | ||
PID=$! | ||
|
||
BLOCKFILTERARG="" | ||
if bitcoind -version | grep -q "v0\.\(19\|2\)"; then | ||
BLOCKFILTERARG="-blockfilterindex=1" | ||
fi | ||
# Allow time for startup | ||
sleep 5 | ||
|
||
FALLBACKFEEARG="" | ||
if bitcoind -version | grep -q "v0\.2"; then | ||
FALLBACKFEEARG="-fallbackfee=0.00001000" | ||
fi | ||
# Pre-create faucet wallet "main" so the test can fund addresses | ||
dash-cli -regtest -datadir="${TESTDIR}/dash" -rpcport=19898 -named createwallet wallet_name=main descriptors=false >/dev/null 2>&1 || true | ||
|
||
bitcoind -regtest $BLOCKFILTERARG $FALLBACKFEEARG \ | ||
-datadir=${TESTDIR}/2 \ | ||
-connect=127.0.0.1:12348 \ | ||
-rpcport=12349 \ | ||
-server=1 \ | ||
-txindex=1 \ | ||
-printtoconsole=0 & | ||
PID2=$! | ||
# Fund the faucet wallet with mature coins | ||
FAUCET_ADDR=$(dash-cli -regtest -datadir="${TESTDIR}/dash" -rpcport=19898 -rpcwallet=main getnewaddress) | ||
dash-cli -regtest -datadir="${TESTDIR}/dash" -rpcport=19898 generatetoaddress 110 "$FAUCET_ADDR" >/dev/null | ||
|
||
# Let it connect to the other node. | ||
sleep 5 | ||
# Export per-node env vars expected by the test (both point to same node) | ||
export WALLET_NODE_RPC_URL="http://127.0.0.1:19898" | ||
export EVO_NODE_RPC_URL="http://127.0.0.1:19898" | ||
export WALLET_NODE_RPC_COOKIE="${TESTDIR}/dash/regtest/.cookie" | ||
export EVO_NODE_RPC_COOKIE="${TESTDIR}/dash/regtest/.cookie" | ||
|
||
RPC_URL=http://localhost:12349 \ | ||
RPC_COOKIE=${TESTDIR}/2/regtest/.cookie \ | ||
cargo run | ||
cargo run | ||
|
||
RESULT=$? | ||
|
||
kill -9 $PID1 $PID2 | ||
kill -9 $PID 2>/dev/null || true | ||
|
||
exit $RESULT | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -83,16 +83,11 @@ pub struct GetNetworkInfoResult { | |||||||||||||||||||||||||||||||||
#[serde(rename = "networkactive")] | ||||||||||||||||||||||||||||||||||
pub network_active: bool, | ||||||||||||||||||||||||||||||||||
pub connections: usize, | ||||||||||||||||||||||||||||||||||
#[serde(rename = "inboundconnections")] | ||||||||||||||||||||||||||||||||||
pub inbound_connections: usize, | ||||||||||||||||||||||||||||||||||
#[serde(rename = "outboundconnections")] | ||||||||||||||||||||||||||||||||||
pub outbound_connections: usize, | ||||||||||||||||||||||||||||||||||
#[serde(rename = "mnconnections")] | ||||||||||||||||||||||||||||||||||
pub mn_connections: usize, | ||||||||||||||||||||||||||||||||||
#[serde(rename = "inboundmnconnections")] | ||||||||||||||||||||||||||||||||||
pub inbound_mn_connections: usize, | ||||||||||||||||||||||||||||||||||
#[serde(rename = "outboundmnconnections")] | ||||||||||||||||||||||||||||||||||
pub outbound_mn_connections: usize, | ||||||||||||||||||||||||||||||||||
pub connections_in: usize, | ||||||||||||||||||||||||||||||||||
pub connections_out: usize, | ||||||||||||||||||||||||||||||||||
pub connections_mn: usize, | ||||||||||||||||||||||||||||||||||
pub connections_mn_in: usize, | ||||||||||||||||||||||||||||||||||
pub connections_mn_out: usize, | ||||||||||||||||||||||||||||||||||
Comment on lines
+86
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Preserve back-compat in GetNetworkInfoResult: add serde aliases + defaults to avoid deserialization breakage across Core versions Nodes that still return the legacy keys (e.g., inboundconnections/outboundconnections/mnconnections/inboundmnconnections/outboundmnconnections) will fail to deserialize since these fields are required and not optional. Add aliases and defaults so both old and new schemas work. Apply this diff: pub connections: usize,
- pub connections_in: usize,
- pub connections_out: usize,
- pub connections_mn: usize,
- pub connections_mn_in: usize,
- pub connections_mn_out: usize,
+ #[serde(default, alias = "inboundconnections")]
+ pub connections_in: usize,
+ #[serde(default, alias = "outboundconnections")]
+ pub connections_out: usize,
+ #[serde(default, alias = "mnconnections")]
+ pub connections_mn: usize,
+ #[serde(default, alias = "inboundmnconnections")]
+ pub connections_mn_in: usize,
+ #[serde(default, alias = "outboundmnconnections")]
+ pub connections_mn_out: usize, Optionally, I can add a small serde test to verify both old and new JSON shapes deserialize correctly. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||
#[serde(rename = "socketevents")] | ||||||||||||||||||||||||||||||||||
pub socket_events: String, | ||||||||||||||||||||||||||||||||||
pub networks: Vec<GetNetworkInfoResultNetwork>, | ||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Make the harness deterministic and safe: trap-based cleanup, readiness wait, and configurable RPC port.
As written,
set -e
will abort before cleanup ifcargo run
fails, leavingdashd
running and causing flaky port conflicts. Also,sleep 5
is racy on CI, and hard-coding port 19898 risks collisions. Apply this consolidated patch:📝 Committable suggestion
🤖 Prompt for AI Agents