Skip to content

Commit

Permalink
fix MG tests for JD SetupConnection flags
Browse files Browse the repository at this point in the history
as already described in the previous commit, we introduced a new JDS config parameter (`async_mining_allowed`)

so now, we need 2 separate tests:
- a JDS that supports async jobs
- a JDS that does not support async jobs

and for each test, we need a mock that:
- sends a `SetupConnection` with flag 0 and asserts the expected outcome
- sends a `SetupConnection` with flag 1 and asserts the expected outcome

if JDS does not support async jobs and receives a `SetupConnection` with flag 1, the expected outcome is `SetupConnection.Error`
in all other cases, the expected outcome is a `SetupConnection.Success` with the same flag as the original `SetupConnection`
  • Loading branch information
plebhash authored and Shourya742 committed Jul 19, 2024
1 parent d18b5e6 commit 76a012d
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Async Job Support
async_mining_allowed = true

# SRI Pool config
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Async Job Support
async_mining_allowed = false

# SRI Pool config
authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n"
cert_validity_sec = 3600

# list of compressed or uncompressed pubkeys for coinbase payout (only supports 1 item in the array at this point)
coinbase_outputs = [
{ output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" },
]

listen_jd_address = "127.0.0.1:34264"

core_rpc_url = ""
core_rpc_port = 18332
core_rpc_user = ""
core_rpc_pass = ""
# Time interval used for JDS mempool update
[mempool_update_interval]
unit = "secs"
value = 1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"doc": [
"This test does",
"Soft mock of JDC",
"Connect to JDS",
"Receive Setup Connection Error as incorrect bits are set"
"Connect to JDS (where it doesn't matter if it supports async jobs or not)",
"Send SetupConnection with flag 0 (no async jobs) and expect SetupConnection.Success with flag 0"
],
"frame_builders": [
{
Expand All @@ -25,13 +25,13 @@
[
[
"flags",
{"U32": 1}
{ "U32": 0 }
]
]
]
}
],
"actiondoc": "This action sends SetupConnection and checks that .Error"
"actiondoc": "This action sends SetupConnection and expects SetupConnection.Success with flag 0"
}
],
"setup_commands": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"version": "2",
"doc": [
"This test does",
"Soft mock of JDC",
"Connect to JDS (that supports async jobs)",
"Send SetupConnection with flag 1 (async jobs) and expect SetupConnection.Success with flag 1"
],
"frame_builders": [
{
"type": "automatic",
"message_id": "test/message-generator/messages/common_messages.json::setup_connection_job_declarator"
}
],
"actions": [
{
"message_ids": ["setup_connection_job_declarator"],
"role": "client",
"results": [
{
"type": "match_message_field",
"value": [
"CommonMessages",
"SetupConnectionSuccess",
[
[
"flags",
{ "U32": 1 }
]
]
]
}
],
"actiondoc": "This action sends SetupConnection and expects SetupConnection.Success with flag 1"
}
],
"setup_commands": [],
"execution_commands": [],
"cleanup_commands": [],
"role": "client",
"downstream": {
"ip": "127.0.0.1",
"port": 34264,
"pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"version": "2",
"doc": [
"This test does",
"Soft mock of JDC",
"Connect to JDS (that does not support async jobs)",
"Send SetupConnection with flag 1 (async jobs) and expect SetupConnection.Error"
],
"frame_builders": [
{
"type": "automatic",
"message_id": "test/message-generator/messages/common_messages.json::setup_connection_job_declarator"
}
],
"actions": [
{
"message_ids": ["setup_connection_job_declarator"],
"role": "client",
"results": [
{
"type": "match_message_type",
"value": "0x02"
},
{
"type": "close_connection"
}
],
"actiondoc": "This action sends SetupConnection and expects SetupConnection.Error"
}
],
"setup_commands": [],
"execution_commands": [],
"cleanup_commands": [],
"role": "client",
"downstream": {
"ip": "127.0.0.1",
"port": 34264,
"pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"jd_server",
"--",
"-c",
"../test/config/jds-setup-connection-flag-test/jds-config.toml"
"../test/config/jds-setupconnection-flag-test/jds-config-with-async-support.toml"
],
"conditions": {
"WithConditions": {
Expand All @@ -40,16 +40,37 @@
"command": "cargo",
"args": [
"run",
"../../test/message-generator/mock/jdc-mock-jds-setup-connection-mock-invalid-flag.json"
"../../test/message-generator/mock/jdc-mock-flag-0-for-jds-setupconnection-tests.json"
],
"conditions": {
"WithConditions": {
"conditions": [
{
"output_string": "MATCHED MESSAGE TYPE 1",
"output_location": "StdOut",
"output_string": "TEST FAILED",
"output_location": "StdErr",
"late_condition": false,
"condition": true
"condition": false
}
],
"timer_secs": 600,
"warn_no_panic": false
}
}
},
{
"command": "cargo",
"args": [
"run",
"../../test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-with-async-support.json"
],
"conditions": {
"WithConditions": {
"conditions": [
{
"output_string": "TEST FAILED",
"output_location": "StdErr",
"late_condition": false,
"condition": false
}
],
"timer_secs": 600,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ cargo llvm-cov --no-report -p pool_sv2
cd ../utils/message-generator/
cargo build

RUST_LOG=debug cargo run ../../test/message-generator/test/jds-setup-connection-flag-test/jds-setup-connection-flag-test.json || { echo 'mg test failed' ; exit 1; }
RUST_LOG=debug cargo run ../../test/message-generator/test/jds-setupconnection-with-async-support/jds-setupconnection-with-async-support.json || { echo 'mg test failed' ; exit 1; }

sleep 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": "2",
"doc": [
"This test does",
"Launch the jd-server"
],
"frame_builders": [
],
"actions": [
],
"setup_commands": [
{
"command": "cargo",
"args": [
"llvm-cov",
"--no-report",
"run",
"-p",
"jd_server",
"--",
"-c",
"../test/config/jds-setupconnection-flag-test/jds-config-without-async-support.toml"
],
"conditions": {
"WithConditions": {
"conditions": [
{
"output_string": "JD INITIALIZED",
"output_location": "StdOut",
"late_condition": false,
"condition": true
}
],
"timer_secs": 300,
"warn_no_panic": false
}
}
},
{
"command": "cargo",
"args": [
"run",
"../../test/message-generator/mock/jdc-mock-flag-0-for-jds-setupconnection-tests.json"
],
"conditions": {
"WithConditions": {
"conditions": [
{
"output_string": "TEST FAILED",
"output_location": "StdErr",
"late_condition": false,
"condition": false
}
],
"timer_secs": 600,
"warn_no_panic": false
}
}
},
{
"command": "cargo",
"args": [
"run",
"../../test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-without-async-support.json"
],
"conditions": {
"WithConditions": {
"conditions": [
{
"output_string": "TEST FAILED",
"output_location": "StdErr",
"late_condition": false,
"condition": false
}
],
"timer_secs": 600,
"warn_no_panic": false
}
}
}
],
"execution_commands": [
],
"cleanup_commands": [
{
"command": "pkill",
"args": ["-f", "jd_server", "-SIGINT"],
"conditions": "None"
}
],
"role": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cd roles
cargo llvm-cov --no-report -p pool_sv2

cd ../utils/message-generator/
cargo build

RUST_LOG=debug cargo run ../../test/message-generator/test/jds-setupconnection-without-async-support/jds-setupconnection-without-async-support.json || { echo 'mg test failed' ; exit 1; }

sleep 10

0 comments on commit 76a012d

Please sign in to comment.