diff --git a/test/config/jdc-check-prev-hash-on-quick-template-update/jdc-config.toml b/test/config/jdc-check-prev-hash-on-quick-template-update/jdc-config.toml new file mode 100644 index 000000000..ecb532110 --- /dev/null +++ b/test/config/jdc-check-prev-hash-on-quick-template-update/jdc-config.toml @@ -0,0 +1,42 @@ +# Local Mining Device Downstream Connection +downstream_address = "127.0.0.1" +downstream_port = 34265 + +# Version support +max_supported_version = 2 +min_supported_version = 2 + +# Minimum extranonce2 size for downstream +# Max value: 16 (leaves 0 bytes for search space splitting of downstreams) +# Max value for CGminer: 8 +# Min value: 2 +min_extranonce2_size = 8 + +# Withhold +withhold = false + +# Auth keys for open encrypted connection downstream +authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" +authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" +cert_validity_sec = 3600 + +# How many time the JDC try to reinitialize itself after a failure +retry = 10 + +tp_address = "127.0.0.1:8442" +tp_authority_pub_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" + + +coinbase_outputs = [ + { output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" }, +] + +[timeout] +unit = "secs" +value = 1 + +[[upstreams]] +authority_pubkey = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" +pool_address = "127.0.0.1:34254" +jd_address = "127.0.0.1:34264" +pool_signature = "Stratum v2 SRI Pool" diff --git a/test/config/jdc-quick-template-update/jdc-config.toml b/test/config/jdc-quick-template-update/jdc-config.toml new file mode 100644 index 000000000..922c3eed1 --- /dev/null +++ b/test/config/jdc-quick-template-update/jdc-config.toml @@ -0,0 +1,42 @@ +# Local Mining Device Downstream Connection +downstream_address = "127.0.0.1" +downstream_port = 34265 + +# Version support +max_supported_version = 2 +min_supported_version = 2 + +# Minimum extranonce2 size for downstream +# Max value: 16 (leaves 0 bytes for search space splitting of downstreams) +# Max value for CGminer: 8 +# Min value: 2 +min_extranonce2_size = 8 + +# Withhold +withhold = false + +# Auth keys for open encrypted connection downstream +authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" +authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" +cert_validity_sec = 3600 + +# How many time the JDC try to reinitialize itself after a failure +retry = 10 + +tp_address = "127.0.0.1:8443" +tp_authority_pub_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" + + +coinbase_outputs = [ + { output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" }, +] + +[timeout] +unit = "secs" +value = 1 + +[[upstreams]] +authority_pubkey = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" +pool_address = "127.0.0.1:34254" +jd_address = "127.0.0.1:34264" +pool_signature = "Stratum v2 SRI Pool" diff --git a/test/config/pool-config-local-tp.toml b/test/config/pool-config-local-tp.toml new file mode 100644 index 000000000..def1e39db --- /dev/null +++ b/test/config/pool-config-local-tp.toml @@ -0,0 +1,14 @@ +listen_address = "127.0.0.1:34254" +tp_address = "127.0.0.1:8442" +listen_jd_address = "127.0.0.1:34264" +authority_public_key = "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" +authority_secret_key = "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" +cert_validity_sec = 3600 +test_only_listen_adress_plain = "0.0.0.0:34250" +# list of coinbase outputs used to build the coinbase tx +# ! right now only one output is supported, so comment all the ones you don't need ! +coinbase_outputs = [ + { output_script_type = "P2WPKH", output_script_value = "036adc3bdf21e6f9a0f0fb0066bf517e5b7909ed1563d6958a10993849a7554075" }, +] +# Pool signature (string to be included in coinbase tx) +pool_signature = "Stratum v2 SRI Pool" \ No newline at end of file diff --git a/test/message-generator/messages/common_messages.json b/test/message-generator/messages/common_messages.json index ff5d200dd..9aa220223 100644 --- a/test/message-generator/messages/common_messages.json +++ b/test/message-generator/messages/common_messages.json @@ -16,6 +16,22 @@ }, "id": "setup_connection_mining_hom" }, + { + "message": { + "type": "SetupConnection", + "protocol": 0, + "min_version": 2, + "max_version": 2, + "flags": 4, + "endpoint_host": "", + "endpoint_port": 0, + "vendor": "", + "hardware_version": "", + "firmware": "", + "device_id": "" + }, + "id": "setup_connection_tproxy" + }, { "message": { "type": "SetupConnection", @@ -71,6 +87,14 @@ "used_version": 2 }, "id": "setup_connection_success_tproxy" + }, + { + "message": { + "type": "SetupConnectionSuccess", + "flags": 1, + "used_version": 2 + }, + "id": "setup_connection_success_jds_to_jdc" } ] diff --git a/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/downstream-mock.json b/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/downstream-mock.json new file mode 100644 index 000000000..568ccfe43 --- /dev/null +++ b/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/downstream-mock.json @@ -0,0 +1,76 @@ +{ + "version": "2", + "doc": [ + "This test does mimic translator proxy" + ], + "mining_messages": [ + { + "message": { + "type": "OpenExtendedMiningChannel", + "request_id": 1, + "user_identity": "ABC", + "nominal_hash_rate": 10, + "max_target": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], + "min_extranonce_size": 16 + }, + "replace_fields": [["request_id", "ARBITRARY"]], + "id": "open_extended_mining_channel" + }, + { + "message": { + "type": "SubmitSharesExtended", + "channel_id": 1, + "sequence_number": 0, + "job_id": 0, + "nonce": 4035255480, + "ntime": 1698941362, + "version": 536870912, + "extranonce":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] + }, + "id": "submit_shares_extended" + } + ], + "frame_builders": [ + { + "type": "automatic", + "message_id": "test/message-generator/messages/common_messages.json::setup_connection_flag_0" + }, + { + "type": "automatic", + "message_id": "open_extended_mining_channel" + }, + { + "type": "automatic", + "message_id": "submit_shares_extended" + } + ], + "actions": [ + { + "message_ids": ["setup_connection_flag_0"], + "role": "client", + "results": [ + { + "type": "match_message_type", + "value": "0x01" + } + ], + "actiondoc": "This action sends a SetupConnection to JDC and check that receives a message type 0x01 from JDC, that is SetupConnectionSuccess" + } + ], + "setup_commands": [], + "execution_commands": [], + "cleanup_commands": [ + { + "command": "sleep", + "args": ["10000000"], + "conditions": "None" + } + ], + "role": "client", + "downstream": { + "ip": "127.0.0.1", + "port": 34265, + "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", + "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" + } +} diff --git a/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/jds-mock.json b/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/jds-mock.json new file mode 100644 index 000000000..81c7dc74b --- /dev/null +++ b/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/jds-mock.json @@ -0,0 +1,392 @@ +{ + "version": "2", + "doc": [ + "This test does", + "Mock a JDS", + "Start listen to the port 34264", + "Receive SetupConnection and reply SetupConnection.Success", + "(template1) Await for AllocateMiningJobToken and reply AllocateMiningJobToken.Success", + "(template2) Await for AllocateMiningJobToken and reply AllocateMiningJobToken.Success", + "(template1) Await for DeclareMiningJob and reply DeclareMiningJob.Success", + "(template2) Await for DeclareMiningJob and reply DeclareMiningJob.Success" + ], + "job_declaration_messages": [ + { + "message": { + "type": "AllocateMiningJobTokenSuccess", + "request_id":0, + "new_mining_job_token":[], + "mining_job_token": [0, 0, 0, 0], + "coinbase_output":[0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 20, 235, 225, 183, 220, 194, 147, 204, 170, 14, 231, 67, 168, 111, 137, 223, 130, 88, 194, 8, 252], + "coinbase_output_max_additional_size": 100, + "async_mining_allowed": false + }, + "replace_fields": [["request_id", "custom_job_req_id_1"]], + "id": "allocate_mining_job_token_success_0" + }, + { + "message": { + "type": "AllocateMiningJobTokenSuccess", + "request_id":1, + "new_mining_job_token":[], + "mining_job_token": [1, 0, 0, 0], + "coinbase_output":[0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 20, 235, 225, 183, 220, 194, 147, 204, 170, 14, 231, 67, 168, 111, 137, 223, 130, 88, 194, 8, 252], + "coinbase_output_max_additional_size": 100, + "async_mining_allowed": false + }, + "replace_fields": [["request_id", "custom_job_req_id_2"]], + "id": "allocate_mining_job_token_success_1" + }, + { + "message": { + "type": "AllocateMiningJobTokenSuccess", + "request_id":1, + "new_mining_job_token":[], + "mining_job_token": [1, 0, 0, 0], + "coinbase_output":[0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 20, 235, 225, 183, 220, 194, 147, 204, 170, 14, 231, 67, 168, 111, 137, 223, 130, 88, 194, 8, 252], + "coinbase_output_max_additional_size": 100, + "async_mining_allowed": false + }, + "replace_fields": [["request_id", "custom_job_req_id_3"]], + "id": "allocate_mining_job_token_success_2" + }, + { + "message": { + "type": "AllocateMiningJobTokenSuccess", + "request_id":1, + "new_mining_job_token":[], + "mining_job_token": [1, 0, 0, 0], + "coinbase_output":[0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 20, 235, 225, 183, 220, 194, 147, 204, 170, 14, 231, 67, 168, 111, 137, 223, 130, 88, 194, 8, 252], + "coinbase_output_max_additional_size": 100, + "async_mining_allowed": false + }, + "replace_fields": [["request_id", "custom_job_req_id_4"]], + "id": "allocate_mining_job_token_success_3" + }, + { + "message": { + "type": "AllocateMiningJobTokenSuccess", + "request_id":1, + "new_mining_job_token":[], + "mining_job_token": [1, 0, 0, 0], + "coinbase_output":[0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 20, 235, 225, 183, 220, 194, 147, 204, 170, 14, 231, 67, 168, 111, 137, 223, 130, 88, 194, 8, 252], + "coinbase_output_max_additional_size": 100, + "async_mining_allowed": false + }, + "replace_fields": [["request_id", "custom_job_req_id_5"]], + "id": "allocate_mining_job_token_success_4" + }, + { + "message": { + "type": "DeclareMiningJobSuccess", + "request_id": 0, + "new_mining_job_token": [0, 0, 0, 0] + }, + "replace_fields": [["request_id", "declare_job_req_id_1"]], + "id": "declare_mining_job_success_0" + }, + { + "message": { + "type": "DeclareMiningJobSuccess", + "request_id": 1, + "new_mining_job_token": [1, 0, 0, 0] + }, + "replace_fields": [["request_id", "declare_job_req_id_2"]], + "id": "declare_mining_job_success_1" + }, + { + "message": { + "type": "DeclareMiningJobSuccess", + "request_id": 1, + "new_mining_job_token": [1, 0, 0, 0] + }, + "replace_fields": [["request_id", "declare_job_req_id_3"]], + "id": "declare_mining_job_success_2" + } + ], + "frame_builders": [ + { + "type": "automatic", + "message_id": "allocate_mining_job_token_success_0" + }, + { + "type": "automatic", + "message_id": "allocate_mining_job_token_success_1" + }, + { + "type": "automatic", + "message_id": "allocate_mining_job_token_success_2" + }, + { + "type": "automatic", + "message_id": "allocate_mining_job_token_success_3" + }, + { + "type": "automatic", + "message_id": "allocate_mining_job_token_success_4" + }, + { + "type": "automatic", + "message_id": "declare_mining_job_success_0" + }, + { + "type": "automatic", + "message_id": "declare_mining_job_success_1" + }, + { + "type": "automatic", + "message_id": "declare_mining_job_success_2" + }, + { + "type": "automatic", + "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy" + }, + { + "type": "automatic", + "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_jds_to_jdc" + } + ], + "actions": [ + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "match_message_type", + "value": "0x00" + } + ], + "actiondoc": "This action checks that a SetupConnection message is received," + }, + { + "message_ids": ["setup_connection_success_jds_to_jdc"], + "role": "server", + "results": [], + "actiondoc": "This action sends back a SetupConnection.Success (setup_connection_success_jds_to_jdc) " + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "JobDeclarationProtocol", + "AllocateMiningJobToken", + [ + [ + "request_id", + "custom_job_req_id_1" + ] + ] + ] + } + ], + "actiondoc": "This action checks receives allocate mining job" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "JobDeclarationProtocol", + "AllocateMiningJobToken", + [ + [ + "request_id", + "custom_job_req_id_2" + ] + ] + ] + } + ], + "actiondoc": "This action checks receives allocate mining job" + }, + { + "message_ids": ["allocate_mining_job_token_success_0"], + "role": "server", + "results": [], + "actiondoc": "This action sends back a AllocateMiningJobToken.Success (allocate_mining_job_token_success)" + }, + { + "message_ids": ["allocate_mining_job_token_success_1"], + "role": "server", + "results": [], + "actiondoc": "This action sends back a AllocateMiningJobToken.Success (allocate_mining_job_token_success)" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "JobDeclarationProtocol", + "DeclareMiningJob", + [ + [ + "request_id", + "declare_job_req_id_1" + ] + ] + ] + } + ], + "actiondoc": "This action checks that a DeclareMiningJob message is received" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "JobDeclarationProtocol", + "AllocateMiningJobToken", + [ + [ + "request_id", + "custom_job_req_id_3" + ] + ] + ] + } + ], + "actiondoc": "This action checks receives allocate mining job" + }, + { + "message_ids": ["allocate_mining_job_token_success_2"], + "role": "server", + "results": [], + "actiondoc": "This action sends back a AllocateMiningJobToken.Success (allocate_mining_job_token_success)" + }, + { + "message_ids": ["declare_mining_job_success_0"], + "role": "server", + "results": [], + "actiondoc": "This action checks that a DeclareMiningJob message is received" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "JobDeclarationProtocol", + "DeclareMiningJob", + [ + [ + "request_id", + "declare_job_req_id_2" + ] + ] + ] + } + ], + "actiondoc": "This action checks that a DeclareMiningJob message is received" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "JobDeclarationProtocol", + "AllocateMiningJobToken", + [ + [ + "request_id", + "custom_job_req_id_4" + ] + ] + ] + } + ], + "actiondoc": "This action checks receives allocate mining job" + }, + { + "message_ids": ["allocate_mining_job_token_success_3"], + "role": "server", + "results": [], + "actiondoc": "This action sends back a AllocateMiningJobToken.Success (allocate_mining_job_token_success)" + }, + { + "message_ids": ["declare_mining_job_success_1"], + "role": "server", + "results": [], + "actiondoc": "This action checks that a DeclareMiningJob message is received" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "JobDeclarationProtocol", + "DeclareMiningJob", + [ + [ + "request_id", + "declare_job_req_id_3" + ] + ] + ] + } + ], + "actiondoc": "This action checks that a DeclareMiningJob message is received" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "JobDeclarationProtocol", + "AllocateMiningJobToken", + [ + [ + "request_id", + "custom_job_req_id_5" + ] + ] + ] + } + ], + "actiondoc": "This action checks receives allocate mining job" + }, + { + "message_ids": ["allocate_mining_job_token_success_4"], + "role": "server", + "results": [], + "actiondoc": "This action sends back a AllocateMiningJobToken.Success (allocate_mining_job_token_success)" + }, + { + "message_ids": ["declare_mining_job_success_2"], + "role": "server", + "results": [], + "actiondoc": "This action checks that a DeclareMiningJob message is received" + } + ], + "setup_commands": [], + "execution_commands": [], + "cleanup_commands": [ + { + "command": "sleep", + "args": ["10000"], + "conditions": "None" + } + ], + "role": "server", + "upstream": { + "ip": "127.0.0.1", + "port": 34264, + "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", + "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" + } +} diff --git a/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/pool-mock.json b/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/pool-mock.json new file mode 100644 index 000000000..8ae932e5f --- /dev/null +++ b/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/pool-mock.json @@ -0,0 +1,167 @@ +{ + "version": "2", + "doc": [ + "This test does", + "Mock a pool", + "Start listen to the port 34254", + "Receive setup_connection", + "Sends setup_connection_success", + "Receive open extended channel", + "Send open extended channel success", + "Receive new custom mining job", + "Send set custom mining job success", + "Receive submit share", + "Send submit share error" + ], + "mining_messages":[ + { + "message": { + "type": "SetCustomMiningJobSuccess", + "request_id":0, + "channel_id":0, + "job_id":0 + }, + "replace_fields": [["request_id", "custom_req_id_1"],["channel_id","custom_channel_id_1"]], + "id": "allocate_custom_mining_job_token_success_1" + }, + { + "message": { + "type": "SetCustomMiningJobSuccess", + "request_id":0, + "channel_id":0, + "job_id":1 + }, + "replace_fields": [["request_id", "custom_req_id_2"],["channel_id","custom_channel_id_2"]], + "id": "allocate_custom_mining_job_token_success_2" + } + ], + "frame_builders": [ + { + "type": "automatic", + "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy" + }, + { + "type": "automatic", + "message_id": "allocate_custom_mining_job_token_success_1" + }, + { + "type": "automatic", + "message_id": "allocate_custom_mining_job_token_success_2" + } + ], + "actions": [ + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "match_message_type", + "value": "0x00" + } + ], + "actiondoc": "This action checks that a Setupconnection message is received from JDC to pool" + }, + { + "message_ids": ["setup_connection_success_tproxy"], + "role": "server", + "results": [], + "actiondoc": "This action checks that a Setupconnection message is received from JDC to pool" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "MiningProtocol", + "SetCustomMiningJob", + [ + [ + "request_id", + "custom_req_id_1" + ], + [ + "channel_id", + "custom_channel_id_1" + ] + ] + ] + } + ], + "actiondoc": "This action checks for SetCustomMiningJob to pool" + }, + { + "message_ids": ["allocate_custom_mining_job_token_success_1"], + "role": "server", + "results": [], + "actiondoc": "This action sends customMiningJobTokenSuccess to JDC " + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "get_message_field", + "value": [ + "MiningProtocol", + "SetCustomMiningJob", + [ + [ + "request_id", + "custom_req_id_2" + ], + [ + "channel_id", + "custom_channel_id_2" + ] + ] + ] + } + ], + "actiondoc": "This action checks for SetCustomMiningJob to pool" + }, + { + "message_ids": ["allocate_custom_mining_job_token_success_2"], + "role": "server", + "results": [], + "actiondoc": "This action sends customMiningJobTokenSuccess to JDC" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "match_message_field", + "value": [ + "MiningProtocol", + "SetCustomMiningJob", + [ + [ + "prev_hash", + {"U32": 89} + ] + ] + ] + } + ], + "actiondoc": "This action checks for SetCustomMiningJob to pool" + } + ], + "setup_commands": [], + "execution_commands": [], + "cleanup_commands": [ + { + "command": "sleep", + "args": ["10000"], + "conditions": "None" + } + ], + "role": "server", + "upstream": { + "ip": "127.0.0.1", + "port": 34254, + "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", + "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" + } +} diff --git a/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/tp-mock.json b/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/tp-mock.json new file mode 100644 index 000000000..724dc3e4c --- /dev/null +++ b/test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/tp-mock.json @@ -0,0 +1,277 @@ +{ + "version": "2", + "doc": [ + "This test does", + "Soft mocking of template provider that sends two templates (NewTemplate message) with very little time in between", + "Listen to port 8443", + "Awaits for other roles setup (5s)", + "Awaits for SetupConnection message (jdc)", + "Responds with SetupConnection.Success (jdc)", + "Sends NewTemplate (new_template)", + "Sends SetNewPrevHash (set_new_prev_hash2)", + "Awaits for RequestTransactionData", + "Responds with RequestTransactionData.Success", + "Sleep for 100ms (very fast time between templates)", + "Sends NewTemplate (new_template2)", + "Sends SetNewPrevHash (set_new_prev_hash2)", + "Awaits for RequestTransactionData", + "Responds with RequestTransactionData.Success" + ], + "template_distribution_messages": [ + { + "message": { + "type": "NewTemplate", + "template_id": 29, + "future_template": true, + "version": 536870912, + "coinbase_tx_version": 2, + "coinbase_prefix": [3, 76, 163, 38, 0], + "coinbase_tx_input_sequence": 4294967295, + "coinbase_tx_value_remaining": 625000000, + "coinbase_tx_outputs_count": 0, + "coinbase_tx_outputs": [], + "coinbase_tx_locktime": 0, + "merkle_path": [] + }, + "id": "new_template" + }, + { + "message": { + "type": "SetNewPrevHash", + "template_id": 29, + "prev_hash": [145, 77, 225, 26, 186, 5, 16, 125, 174, 40, 238, 200, 210, 191, 188, 87, 191, 246, 242, 221, 8, 20, 202, 200, 97, 139, 241, 73, 137, 201, 28, 0], + "header_timestamp": 1671039088, + "n_bits": 545259519, + "target": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127] + }, + "id": "set_new_prev_hash" + }, + { + "message": { + "type": "RequestTransactionDataSuccess", + "template_id": 29, + "excess_data": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + "transaction_list": [] + }, + "id": "request_transaction_data_success" + }, + { + "message": { + "type": "NewTemplate", + "template_id": 30, + "future_template": true, + "version": 536870912, + "coinbase_tx_version": 2, + "coinbase_prefix": [3, 76, 163, 38, 0], + "coinbase_tx_input_sequence": 4294967295, + "coinbase_tx_value_remaining": 625000000, + "coinbase_tx_outputs_count": 0, + "coinbase_tx_outputs": [], + "coinbase_tx_locktime": 0, + "merkle_path": [] + }, + "id": "new_template2" + }, + { + "message": { + "type": "SetNewPrevHash", + "template_id": 30, + "prev_hash": [145, 77, 225, 26, 186, 5, 16, 125, 174, 40, 238, 200, 210, 191, 188, 87, 191, 246, 242, 221, 8, 20, 202, 200, 97, 139, 241, 73, 137, 201, 28, 0], + "header_timestamp": 1671039088, + "n_bits": 545259519, + "target": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127] + }, + "id": "set_new_prev_hash2" + }, + { + "message": { + "type": "RequestTransactionDataSuccess", + "template_id": 30, + "excess_data": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + "transaction_list": [] + }, + "id": "request_transaction_data_success2" + }, + { + "message": { + "type": "NewTemplate", + "template_id": 31, + "future_template": false, + "version": 536870912, + "coinbase_tx_version": 2, + "coinbase_prefix": [3, 76, 163, 38, 0], + "coinbase_tx_input_sequence": 4294967295, + "coinbase_tx_value_remaining": 625000000, + "coinbase_tx_outputs_count": 0, + "coinbase_tx_outputs": [], + "coinbase_tx_locktime": 0, + "merkle_path": [] + }, + "id": "new_template3" + }, + { + "message": { + "type": "RequestTransactionDataSuccess", + "template_id": 31, + "excess_data": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], + "transaction_list": [] + }, + "id": "request_transaction_data_success3" + } + ], + "frame_builders": [ + { + "type": "automatic", + "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_template_distribution" + }, + { + "type": "automatic", + "message_id": "new_template" + }, + { + "type": "automatic", + "message_id": "set_new_prev_hash" + }, + { + "type": "automatic", + "message_id": "new_template2" + }, + { + "type": "automatic", + "message_id": "set_new_prev_hash2" + }, + { + "type":"automatic", + "message_id": "request_transaction_data_success" + }, + { + "type":"automatic", + "message_id": "request_transaction_data_success2" + }, + { + "type":"automatic", + "message_id": "new_template3" + }, + { + "type":"automatic", + "message_id": "request_transaction_data_success3" + } + ], + "actions": [ + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "match_message_type", + "value": "0x00" + } + ], + "actiondoc": "(jdc) This action checks that a SetupConnection message is received" + }, + { + "message_ids": ["setup_connection_success_template_distribution"], + "role": "server", + "results": [], + "actiondoc": "(jdc) This action sends SetupConnection.Success with flag 2 (TD protocol)" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "match_message_type", + "value": "0x70" + } + ], + "actiondoc": "This action checks that a message CoinbaseOutputDataSize is received" + }, + { + "message_ids": ["new_template","set_new_prev_hash"], + "role": "server", + "results": [], + "actiondoc": "This action sends NewTemplate and SetNewPrevHash" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "match_message_type", + "value": "0x73" + } + ], + "actiondoc": "This action checks RequestTransactionData received" + }, + { + "message_ids":["request_transaction_data_success"], + "role":"server", + "results":[], + "actiondoc":"This action sends RequestTransactionDataSuccess" + }, + { + "message_ids": ["new_template2","set_new_prev_hash2"], + "role": "server", + "results": [], + "actiondoc": "This action sends new template2 and new prev hash2" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "match_message_type", + "value": "0x73" + } + ], + "actiondoc": "This action checks RequestTransactionData received" + }, + { + "message_ids":["request_transaction_data_success2"], + "role":"server", + "results":[], + "actiondoc":"This action sends RequestTransactionDataSuccess" + }, + { + "message_ids":["new_template3"], + "role":"server", + "results":[], + "actiondoc":"This action sends new template" + }, + { + "message_ids": [], + "role": "server", + "results": [ + { + "type": "match_message_type", + "value": "0x73" + } + ], + "actiondoc": "This action checks RequestTransactionData received" + }, + { + "message_ids":["request_transaction_data_success3"], + "role":"server", + "results":[], + "actiondoc":"This action sends RequestTransactionDataSuccess" + } + ], + "setup_commands": [ + + ], + "execution_commands": [], + "cleanup_commands": [ + { + "command": "sleep", + "args": ["100000"], + "conditions": "None" + } + ], + "role": "server", + "upstream": { + "ip": "127.0.0.1", + "port": 8442, + "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", + "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" + } +} diff --git a/test/message-generator/test/jdc-check-prev-hash-on-quick-template-updates/jdc-check-prev-hash-on-quick-template-updates.json b/test/message-generator/test/jdc-check-prev-hash-on-quick-template-updates/jdc-check-prev-hash-on-quick-template-updates.json new file mode 100644 index 000000000..369eb3f6a --- /dev/null +++ b/test/message-generator/test/jdc-check-prev-hash-on-quick-template-updates/jdc-check-prev-hash-on-quick-template-updates.json @@ -0,0 +1,166 @@ +{ + "version": "2", + "doc": [ + "This test does", + "Mock TP1 on port: 8442", + "Launch real pool on port: 34254", + "Mock JDS on port: 34264", + "Launch real JDC on port: 34265", + "Mock TP2 on port: 8443", + "Mock Downstream", + "Mock TP1 spun up", + "Pool spun up", + "Pool sends setup connection request to TP1", + "TP1 responses back with setupConnection success", + "Pool sends CoinbaseOutputDataSize to TP1", + "Mock JDS spuns up", + "JDC spuns up", + "Mock TP2 spuns up", + "Mock Downstream spuns up", + "JDC sends setupConnection request to JDS", + "JDS responses back with setupConnection success to JDC", + "JDC sends setup connection request to TP2", + "TP2 responses back with setupConnection success", + "JDC sends CoinbaseOutputDataSize to TP2", + "Downstream sends setup connection request to JDC", + "JDC sends setup connection success request to downstream", + "", + "", + "", + "ascascas", + "This test does", + "Mock Pool on port: 34254" + ], + "frame_builders": [], + "actions": [], + "setup_commands": [ + { + "command": "cargo", + "args": [ + "run", + "../../test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/pool-mock.json" + ], + "conditions": { + "WithConditions": { + "conditions": [ + { + "output_string": "", + "output_location": "StdErr", + "condition": true, + "late_condition": false + } + ], + "timer_secs": 1000000, + "warn_no_panic": false + } + } + }, + { + "command": "cargo", + "args": [ + "run", + "../../test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/jds-mock.json" + ], + + "conditions": { + "WithConditions": { + "conditions": [ + { + "output_string": "", + "output_location": "StdErr", + "condition": true, + "late_condition": false + } + ], + "timer_secs": 60000, + "warn_no_panic": false + } + } + }, + { + "command": "cargo", + "args": [ + "llvm-cov", + "--no-report", + "run", + "-p", + "jd_client", + "--", + "-c", + "../test/config/jdc-check-prev-hash-on-quick-template-update/jdc-config.toml" + ], + "conditions": { + "WithConditions": { + "conditions": [ + { + "output_string": "JD CONNECTED", + "output_location": "StdOut", + "late_condition": false, + "condition": true + } + ], + "timer_secs": 600000, + "warn_no_panic": false + } + } + }, + { + "command": "cargo", + "args": [ + "run", + "../../test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/tp-mock.json" + ], + + "conditions": { + "WithConditions": { + "conditions": [ + { + "output_string": "", + "output_location": "StdErr", + "condition": true, + "late_condition": false + } + ], + "timer_secs": 1000000, + "warn_no_panic": false + } + } + }, + { + "command": "cargo", + "args": [ + "run", + "../../test/message-generator/mock/jdc-check-prev-hash-on-quick-template-updates/downstream-mock.json" + ], + + "conditions": { + "WithConditions": { + "conditions": [ + { + "output_string": "", + "output_location": "StdErr", + "condition": true, + "late_condition": false + } + ], + "timer_secs": 10000000, + "warn_no_panic": true + } + } + } + ], + "execution_commands": [], + "cleanup_commands": [ + { + "command": "sleep", + "args": ["10000"], + "conditions": "None" + }, + { + "command": "pkill", + "args": ["-f", "jd_client", "-SIGINT"], + "conditions": "None" + } + ], + "role": "none" +} diff --git a/test/message-generator/test/jdc-check-prev-hash-on-quick-template-updates/jdc-check-prev-hash-on-quick-template-updates.sh b/test/message-generator/test/jdc-check-prev-hash-on-quick-template-updates/jdc-check-prev-hash-on-quick-template-updates.sh new file mode 100644 index 000000000..39dbe9796 --- /dev/null +++ b/test/message-generator/test/jdc-check-prev-hash-on-quick-template-updates/jdc-check-prev-hash-on-quick-template-updates.sh @@ -0,0 +1,10 @@ +cd roles +cargo llvm-cov --no-report -p jd_client +cargo llvm-cov --no-report -p pool_sv2 + +cd ../utils/message-generator/ +cargo build + +RUST_LOG=debug cargo run ../../test/message-generator/test/jdc-check-prev-hash-on-quick-template-updates/jdc-check-prev-hash-on-quick-template-updates.json || { echo 'mg test failed' ; exit 1; } + +sleep 10