Skip to content

Commit acfd407

Browse files
authored
fix: update expected error codes in DRep delegation test cases + enhancements (#592)
- Changed expected error code from 5040 to 5000 in multiple DRep delegation JSON test files to reflect updated error handling. - Added new integration test cases for DRep vote delegation, covering scenarios with matching and mismatching types, as well as handling of CIP-129 prefixes. - Revised existing test cases to ensure correct DRep id handling and error messages. - Updated DRep delegation guide to clarify the requirement of the `type` field for both key_hash and script_hash formats.
1 parent 85ab335 commit acfd407

14 files changed

+277
-131
lines changed

docs/docs/user-guides/drep-delegation.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ A DRep vote delegation operation requires a staking credential and the DRep info
3939
**Important:** The `type` field is always required regardless of hash format.
4040

4141
_Examples:_
42-
- With prefix: `"id": "0374984fae4ca1715fa1f8759f9d871015ac87f449a85dea6cf9956da1"` (prefix `03` will be stripped)
43-
- Without prefix: `"id": "74984fae4ca1715fa1f8759f9d871015ac87f449a85dea6cf9956da1"`
42+
- With prefix (key hash): `"id": "22abcdef0123456789abcdef0123456789abcdef0123456789abcdef01"` (header `0x22` indicates DRep key_hash)
43+
- With prefix (script hash): `"id": "23abcdef0123456789abcdef0123456789abcdef0123456789abcdef01"` (header `0x23` indicates DRep script_hash)
44+
- Without prefix: `"id": "abcdef0123456789abcdef0123456789abcdef0123456789abcdef01"`
4445

45-
Both examples require `"type": "key_hash"` to be specified.
46+
Both prefixed and raw formats still require a `"type"` to be specified (`"key_hash"` or `"script_hash"`).
4647

4748
The API automatically detects the format and handles the prefix internally. When returning data, the API maintains the 28-byte format with separate type field for consistency.
4849
:::
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"test_name": "CIP-129 key_hash with matching type",
3+
"description": "Positive: CIP-129 prefix (0x22=key_hash) with matching type declaration",
4+
"request_body": {
5+
"network_identifier": {
6+
"blockchain": "cardano",
7+
"network": "{{networkId}}"
8+
},
9+
"operations": [
10+
{
11+
"operation_identifier": {
12+
"index": 0
13+
},
14+
"type": "input",
15+
"account": {
16+
"address": "addr_test1qz8swh9a7tga0u62lxs6dvnkmpxd0dyeeqx27csh6ywx7qplrv4wtdpvnh6wffzch0uakzhh7uwyvd4asda3zzay0qpqcplwh0"
17+
},
18+
"amount": {
19+
"value": "-2000000",
20+
"currency": {
21+
"symbol": "ADA",
22+
"decimals": 6
23+
}
24+
},
25+
"coin_change": {
26+
"coin_identifier": {
27+
"identifier": "4f25fd8cca835af21f3ac375bac601f97ead75f2e79143bdf71fe2c4be043e8f:0"
28+
},
29+
"coin_action": "coin_spent"
30+
}
31+
},
32+
{
33+
"operation_identifier": {
34+
"index": 1
35+
},
36+
"type": "output",
37+
"account": {
38+
"address": "addr_test1qz8swh9a7tga0u62lxs6dvnkmpxd0dyeeqx27csh6ywx7qplrv4wtdpvnh6wffzch0uakzhh7uwyvd4asda3zzay0qpqcplwh0"
39+
},
40+
"amount": {
41+
"value": "1626887",
42+
"currency": {
43+
"symbol": "ADA",
44+
"decimals": 6
45+
}
46+
}
47+
},
48+
{
49+
"operation_identifier": {
50+
"index": 2
51+
},
52+
"type": "dRepVoteDelegation",
53+
"account": {
54+
"address": "stake_test1uql3k2h9kskfma8y53vth7wmptmlw8zxx67cx7c3pwj8sqs6zl0wr"
55+
},
56+
"metadata": {
57+
"staking_credential": {
58+
"hex_bytes": "fdbee86a702c49d23f45ab80e697b93ec48b744d5f413ef59c338c3f7b2d2de8",
59+
"curve_type": "edwards25519"
60+
},
61+
"drep": {
62+
"id": "22f72050aa252ccc6bf75747184910c0b9386298167656f935d6b6c26a",
63+
"type": "key_hash"
64+
}
65+
}
66+
}
67+
],
68+
"metadata": {
69+
"ttl": 100454286,
70+
"protocol_parameters": {
71+
"coinsPerUtxoSize": "4310",
72+
"maxTxSize": 16384,
73+
"maxValSize": 5000,
74+
"keyDeposit": "2000000",
75+
"maxCollateralInputs": 3,
76+
"minFeeCoefficient": 44,
77+
"minFeeConstant": 155381,
78+
"minPoolCost": "170000000",
79+
"poolDeposit": "500000000",
80+
"protocol": 10
81+
}
82+
}
83+
},
84+
"expected_response": {
85+
"unsigned_transaction": "82790180613530306439303130323831383235383230346632356664386363613833356166323166336163333735626163363031663937656164373566326537393134336264663731666532633462653034336538663030303138313832353833393030386630373563626466326431643766333461663961316136623237366438346364376234393963383063616636323137643131633666303033663162326165356234326339646634653461343538626266396462306166376637316334363336626438333762313130626134373830323161303031386433303730323161303030356231373930333161303566636366386530346439303130323831383330393832303035383163336631623261653562343263396466346534613435386262663964623061663766373163343633366264383337623131306261343738303238323030353831636637323035306161323532636363366266373537343731383439313063306239333836323938313637363536663933356436623663323661a16a6f7065726174696f6e7383a5746f7065726174696f6e5f6964656e746966696572a165696e64657800676163636f756e74a16761646472657373786c616464725f7465737431717a38737768396137746761307536326c78733664766e6b6d707864306479656571783237637368367977783771706c72763477746470766e68367766667a63683075616b7a68683775777976643461736461337a7a61793071707163706c77683066616d6f756e74a26863757272656e6379a26673796d626f6c6341444168646563696d616c73066576616c7565682d323030303030306b636f696e5f6368616e6765a26f636f696e5f6964656e746966696572a16a6964656e7469666965727842346632356664386363613833356166323166336163333735626163363031663937656164373566326537393134336264663731666532633462653034336538663a306b636f696e5f616374696f6e6a636f696e5f7370656e74647479706565696e707574a4746f7065726174696f6e5f6964656e746966696572a165696e64657801676163636f756e74a16761646472657373786c616464725f7465737431717a38737768396137746761307536326c78733664766e6b6d707864306479656571783237637368367977783771706c72763477746470766e68367766667a63683075616b7a68683775777976643461736461337a7a61793071707163706c77683066616d6f756e74a26863757272656e6379a26673796d626f6c6341444168646563696d616c73066576616c756567313632363838376474797065666f7574707574a4746f7065726174696f6e5f6964656e746966696572a165696e64657802676163636f756e74a1676164647265737378407374616b655f746573743175716c336b3268396b736b666d613879353376746837776d70746d6c77387a78783637637837633370776a38737173367a6c307772686d65746164617461a2727374616b696e675f63726564656e7469616ca2696865785f62797465737840666462656538366137303263343964323366343561623830653639376239336563343862373434643566343133656635396333333863336637623264326465386a63757276655f747970656c6564776172647332353531396464726570a2626964783866373230353061613235326363633662663735373437313834393130633062393338363239383136373635366639333564366236633236616474797065686b65795f6861736864747970657264526570566f746544656c65676174696f6e",
86+
"payloads": [
87+
{
88+
"account_identifier": {
89+
"address": "stake_test1uql3k2h9kskfma8y53vth7wmptmlw8zxx67cx7c3pwj8sqs6zl0wr"
90+
},
91+
"hex_bytes": "a7bce1c91f9e676f55c95755b9fd9903e702d5ae4fd1d5d5c89fec1fe5b1dfbe",
92+
"signature_type": "ed25519"
93+
},
94+
{
95+
"account_identifier": {
96+
"address": "addr_test1qz8swh9a7tga0u62lxs6dvnkmpxd0dyeeqx27csh6ywx7qplrv4wtdpvnh6wffzch0uakzhh7uwyvd4asda3zzay0qpqcplwh0"
97+
},
98+
"hex_bytes": "a7bce1c91f9e676f55c95755b9fd9903e702d5ae4fd1d5d5c89fec1fe5b1dfbe",
99+
"signature_type": "ed25519"
100+
}
101+
]
102+
}
103+
}

tests/integration/golden_examples/rosetta_java/construction/payloads/drep_vote_delegation/cip129_mismatch_type.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"test_name": "(-) cip129 mismatch type",
3-
"description": "Negative test: Test case: (-) cip129 mismatch type",
2+
"test_name": "(-) CIP-129 header type mismatch",
3+
"description": "Negative: DRep id header indicates script-hash but declared drep.type is key_hash",
44
"request_body": {
55
"network_identifier": {
66
"blockchain": "cardano",
@@ -59,8 +59,8 @@
5959
"curve_type": "edwards25519"
6060
},
6161
"drep": {
62-
"id": "03f72050aa252ccc6bf75747184910c0b9386298167656f935d6b6c26a",
63-
"type": "script_hash"
62+
"id": "23f72050aa252ccc6bf75747184910c0b9386298167656f935d6b6c26a",
63+
"type": "key_hash"
6464
}
6565
}
6666
}
@@ -82,8 +82,8 @@
8282
}
8383
},
8484
"expected_error": {
85-
"code": 5037,
86-
"message": "Invalid drep type",
87-
"description": "This should fail due to invalid operations"
85+
"code": 5045,
86+
"message": "There is a mismatch in the drep id header and drep type. Drep id header type and drep type should match.",
87+
"retriable": false
8888
}
89-
}
89+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"test_name": "CIP-129 script_hash with matching type",
3+
"description": "Positive: CIP-129 prefix (0x23=script_hash) with matching type declaration",
4+
"request_body": {
5+
"network_identifier": {
6+
"blockchain": "cardano",
7+
"network": "{{networkId}}"
8+
},
9+
"operations": [
10+
{
11+
"operation_identifier": {
12+
"index": 0
13+
},
14+
"type": "input",
15+
"account": {
16+
"address": "addr_test1qz8swh9a7tga0u62lxs6dvnkmpxd0dyeeqx27csh6ywx7qplrv4wtdpvnh6wffzch0uakzhh7uwyvd4asda3zzay0qpqcplwh0"
17+
},
18+
"amount": {
19+
"value": "-2000000",
20+
"currency": {
21+
"symbol": "ADA",
22+
"decimals": 6
23+
}
24+
},
25+
"coin_change": {
26+
"coin_identifier": {
27+
"identifier": "5f26fd8cca835af21f3ac375bac601f97ead75f2e79143bdf71fe2c4be043e8f:0"
28+
},
29+
"coin_action": "coin_spent"
30+
}
31+
},
32+
{
33+
"operation_identifier": {
34+
"index": 1
35+
},
36+
"type": "output",
37+
"account": {
38+
"address": "addr_test1qz8swh9a7tga0u62lxs6dvnkmpxd0dyeeqx27csh6ywx7qplrv4wtdpvnh6wffzch0uakzhh7uwyvd4asda3zzay0qpqcplwh0"
39+
},
40+
"amount": {
41+
"value": "1626887",
42+
"currency": {
43+
"symbol": "ADA",
44+
"decimals": 6
45+
}
46+
}
47+
},
48+
{
49+
"operation_identifier": {
50+
"index": 2
51+
},
52+
"type": "dRepVoteDelegation",
53+
"account": {
54+
"address": "stake_test1uql3k2h9kskfma8y53vth7wmptmlw8zxx67cx7c3pwj8sqs6zl0wr"
55+
},
56+
"metadata": {
57+
"staking_credential": {
58+
"hex_bytes": "fdbee86a702c49d23f45ab80e697b93ec48b744d5f413ef59c338c3f7b2d2de8",
59+
"curve_type": "edwards25519"
60+
},
61+
"drep": {
62+
"id": "232d4cb680b5f400d3521d272b4295d61150e0eff3950ef4285406a953",
63+
"type": "script_hash"
64+
}
65+
}
66+
}
67+
],
68+
"metadata": {
69+
"ttl": 100454286,
70+
"protocol_parameters": {
71+
"coinsPerUtxoSize": "4310",
72+
"maxTxSize": 16384,
73+
"maxValSize": 5000,
74+
"keyDeposit": "2000000",
75+
"maxCollateralInputs": 3,
76+
"minFeeCoefficient": 44,
77+
"minFeeConstant": 155381,
78+
"minPoolCost": "170000000",
79+
"poolDeposit": "500000000",
80+
"protocol": 10
81+
}
82+
}
83+
},
84+
"expected_response": {
85+
"unsigned_transaction": "82790180613530306439303130323831383235383230356632366664386363613833356166323166336163333735626163363031663937656164373566326537393134336264663731666532633462653034336538663030303138313832353833393030386630373563626466326431643766333461663961316136623237366438346364376234393963383063616636323137643131633666303033663162326165356234326339646634653461343538626266396462306166376637316334363336626438333762313130626134373830323161303031386433303730323161303030356231373930333161303566636366386530346439303130323831383330393832303035383163336631623261653562343263396466346534613435386262663964623061663766373163343633366264383337623131306261343738303238323031353831633264346362363830623566343030643335323164323732623432393564363131353065306566663339353065663432383534303661393533a16a6f7065726174696f6e7383a5746f7065726174696f6e5f6964656e746966696572a165696e64657800676163636f756e74a16761646472657373786c616464725f7465737431717a38737768396137746761307536326c78733664766e6b6d707864306479656571783237637368367977783771706c72763477746470766e68367766667a63683075616b7a68683775777976643461736461337a7a61793071707163706c77683066616d6f756e74a26863757272656e6379a26673796d626f6c6341444168646563696d616c73066576616c7565682d323030303030306b636f696e5f6368616e6765a26f636f696e5f6964656e746966696572a16a6964656e7469666965727842356632366664386363613833356166323166336163333735626163363031663937656164373566326537393134336264663731666532633462653034336538663a306b636f696e5f616374696f6e6a636f696e5f7370656e74647479706565696e707574a4746f7065726174696f6e5f6964656e746966696572a165696e64657801676163636f756e74a16761646472657373786c616464725f7465737431717a38737768396137746761307536326c78733664766e6b6d707864306479656571783237637368367977783771706c72763477746470766e68367766667a63683075616b7a68683775777976643461736461337a7a61793071707163706c77683066616d6f756e74a26863757272656e6379a26673796d626f6c6341444168646563696d616c73066576616c756567313632363838376474797065666f7574707574a4746f7065726174696f6e5f6964656e746966696572a165696e64657802676163636f756e74a1676164647265737378407374616b655f746573743175716c336b3268396b736b666d613879353376746837776d70746d6c77387a78783637637837633370776a38737173367a6c307772686d65746164617461a2727374616b696e675f63726564656e7469616ca2696865785f62797465737840666462656538366137303263343964323366343561623830653639376239336563343862373434643566343133656635396333333863336637623264326465386a63757276655f747970656c6564776172647332353531396464726570a26269647838326434636236383062356634303064333532316432373262343239356436313135306530656666333935306566343238353430366139353364747970656b7363726970745f6861736864747970657264526570566f746544656c65676174696f6e",
86+
"payloads": [
87+
{
88+
"account_identifier": {
89+
"address": "stake_test1uql3k2h9kskfma8y53vth7wmptmlw8zxx67cx7c3pwj8sqs6zl0wr"
90+
},
91+
"hex_bytes": "faa688aa32419d2b371c8e1025d5d52b02f17606e47bbbb742e2e57ac0bb0dce",
92+
"signature_type": "ed25519"
93+
},
94+
{
95+
"account_identifier": {
96+
"address": "addr_test1qz8swh9a7tga0u62lxs6dvnkmpxd0dyeeqx27csh6ywx7qplrv4wtdpvnh6wffzch0uakzhh7uwyvd4asda3zzay0qpqcplwh0"
97+
},
98+
"hex_bytes": "faa688aa32419d2b371c8e1025d5d52b02f17606e47bbbb742e2e57ac0bb0dce",
99+
"signature_type": "ed25519"
100+
}
101+
]
102+
}
103+
}

tests/integration/golden_examples/rosetta_java/construction/payloads/drep_vote_delegation/drep_delegation_script_hash_with_cip129_prefix.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"test_name": "drep delegation script hash with cip129 prefix",
3-
"description": "Test: Test case: drep delegation script hash with cip129 prefix",
2+
"test_name": "(-) CIP-129 script prefix without type",
3+
"description": "Negative: DRep id includes CIP-129 script-hash prefix but omits required drep.type",
44
"request_body": {
55
"network_identifier": {
66
"blockchain": "cardano",
@@ -59,7 +59,7 @@
5959
"curve_type": "edwards25519"
6060
},
6161
"drep": {
62-
"id": "042d4cb680b5f400d3521d272b4295d61150e0eff3950ef4285406a953"
62+
"id": "232d4cb680b5f400d3521d272b4295d61150e0eff3950ef4285406a953"
6363
}
6464
}
6565
}
@@ -81,8 +81,11 @@
8181
}
8282
},
8383
"expected_error": {
84-
"code": 5040,
85-
"message": "Missing drep type",
84+
"code": 5000,
85+
"message": "An error occurred",
86+
"details": {
87+
"message": "An error occurred for request [ID]: [operations[2].metadata.drep.type must not be null]"
88+
},
8689
"description": "This test case may fail due to specific operation requirements"
8790
}
88-
}
91+
}

tests/integration/golden_examples/rosetta_java/construction/payloads/drep_vote_delegation/drep_delegation_with_cip129_prefix.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"test_name": "drep delegation with cip129 prefix",
3-
"description": "Test: Test case: drep delegation with cip129 prefix",
2+
"test_name": "(-) CIP-129 key prefix without type",
3+
"description": "Negative: DRep id includes CIP-129 key-hash prefix but omits required drep.type",
44
"request_body": {
55
"network_identifier": {
66
"blockchain": "cardano",
@@ -59,7 +59,7 @@
5959
"curve_type": "edwards25519"
6060
},
6161
"drep": {
62-
"id": "03f72050aa252ccc6bf75747184910c0b9386298167656f935d6b6c26a"
62+
"id": "22f72050aa252ccc6bf75747184910c0b9386298167656f935d6b6c26a"
6363
}
6464
}
6565
}
@@ -81,8 +81,11 @@
8181
}
8282
},
8383
"expected_error": {
84-
"code": 5040,
85-
"message": "Missing drep type",
84+
"code": 5000,
85+
"message": "An error occurred",
86+
"details": {
87+
"message": "An error occurred for request [ID]: [operations[2].metadata.drep.type must not be null]"
88+
},
8689
"description": "This test case may fail due to specific operation requirements"
8790
}
88-
}
91+
}

tests/integration/golden_examples/rosetta_java/construction/payloads/drep_vote_delegation/drep_id_provided_for_abstain.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"test_name": "(-) drep id provided for abstain",
3-
"description": "Payloads for (-) drep id provided for abstain",
2+
"test_name": "drep id provided for abstain (allowed)",
3+
"description": "Providing a DRep id with abstain is allowed; id is ignored",
44
"request_body": {
55
"network_identifier": {
66
"blockchain": "cardano",
@@ -100,4 +100,4 @@
100100
}
101101
]
102102
}
103-
}
103+
}

tests/integration/golden_examples/rosetta_java/construction/payloads/drep_vote_delegation/invalid_cip129_prefix.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"test_name": "(-) invalid cip129 prefix",
3-
"description": "Negative test: Test case: (-) invalid cip129 prefix",
2+
"test_name": "(-) invalid CIP-129 prefix",
3+
"description": "Negative: DRep id has an invalid CIP-129 header byte (not key or script)",
44
"request_body": {
55
"network_identifier": {
66
"blockchain": "cardano",
@@ -59,7 +59,8 @@
5959
"curve_type": "edwards25519"
6060
},
6161
"drep": {
62-
"id": "01f72050aa252ccc6bf75747184910c0b9386298167656f935d6b6c26a"
62+
"id": "01f72050aa252ccc6bf75747184910c0b9386298167656f935d6b6c26a",
63+
"type": "key_hash"
6364
}
6465
}
6566
}
@@ -81,8 +82,8 @@
8182
}
8283
},
8384
"expected_error": {
84-
"code": 5040,
85-
"message": "Missing drep type",
86-
"description": "This should fail due to invalid operations"
85+
"code": 5037,
86+
"message": "Invalid drep type",
87+
"retriable": false
8788
}
88-
}
89+
}

0 commit comments

Comments
 (0)