Skip to content
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

Extend BidAddr re RC5 #123

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions tests/data/era/era_summary_v2_delegator_kind_purse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"block_hash": "34f7c0246c6dd3b4ae7161a59c6834a9aaa12f74b8d2c4d16ec347a9b8a90407",
"era_id": 15383,
"stored_value": {
"EraInfo": {
"seigniorage_allocations": [
{
"Validator": {
"validator_public_key": "01032146b0b9de01e26aaec7b0d1769920de94681dbd432c3530bfe591752ded6c",
"amount": "100542274855185"
}
},
{
"Validator": {
"validator_public_key": "01032146b0b9de01e26aaec7b0d1769920de94681dbd432c3530bfe591752ded6c",
"amount": "84485499521"
}
},
{
"Validator": {
"validator_public_key": "0126d4637eb0c0769274f03a696df1112383fa621c9f73f57af4c5c0fbadafa8cf",
"amount": "88379190136305"
}
},
{
"Validator": {
"validator_public_key": "0126d4637eb0c0769274f03a696df1112383fa621c9f73f57af4c5c0fbadafa8cf",
"amount": "84493160372"
}
},
{
"Validator": {
"validator_public_key": "0140afe8f752e5ff100e0189c080bc207e8805b3e5e82f792ec608de2f11f39f6c",
"amount": "99527758907914"
}
},
{
"Validator": {
"validator_public_key": "0140afe8f752e5ff100e0189c080bc207e8805b3e5e82f792ec608de2f11f39f6c",
"amount": "84483913675"
}
},
{
"Validator": {
"validator_public_key": "017536433a73f7562526f3e9fcb8d720428ae2d28788a9909f3c6f637a9d848a4b",
"amount": "83817182779548"
}
},
{
"Validator": {
"validator_public_key": "017536433a73f7562526f3e9fcb8d720428ae2d28788a9909f3c6f637a9d848a4b",
"amount": "84494615864"
}
},
{
"Delegator": {
"delegator_kind": {
"Purse": "de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae98"
},
"validator_public_key": "01197f6b23e16c8532c6abc838facd5ea789be0c76b2920334039bfa8b3d368d61",
"amount": "1000000000"
}
}
]
}
},
"state_root_hash": "6e8ed1a812f9518ee39277f77f707955a3f73b2c775df7424b2da175625b8f2e",
"merkle_proof": "010000000b000000000000000000000000000000000000000000000000000000000000000007080000000001032146b0b9de01e26aaec7b0d1769920de94681dbd432c3530bfe591752ded6c0611e19352715b0001032146b0b9de01e26aaec7b0d1769920de94681dbd432c3530bfe591752ded6c05816abaab13000126d4637eb0c0769274f03a696df1112383fa621c9f73f57af4c5c0fbadafa8cf06f1cd3b626150000126d4637eb0c0769274f03a696df1112383fa621c9f73f57af4c5c0fbadafa8cf05b44f2fac13000140afe8f752e5ff100e0189c080bc207e8805b3e5e82f792ec608de2f11f39f6c060a0ab71c855a000140afe8f752e5ff100e0189c080bc207e8805b3e5e82f792ec608de2f11f39f6c05cb37a2ab1300017536433a73f7562526f3e9fcb8d720428ae2d28788a9909f3c6f637a9d848a4b069cd867353b4c00017536433a73f7562526f3e9fcb8d720428ae2d28788a9909f3c6f637a9d848a4b05388545ac1301000000000b140000000001510e5f331b1a84b14252fe3913d3afb152f287462714c108b2cd03c29164207801018eb48c820fb106611a9dc65b5516c76267c7a546c8b0f7f87ccad67dc1afa1f50201d39dc1d39d36b8c59e9355cdd55adf4d769cc6d63db915fe69ea94a24e8454840301a86c2de6d91155a59adda00169c1372f409b8e71aca5ecc95888e75ab4df366e0401744d6727bd6c08d70a1d49fa3fcb0397230595e628ed0c52f5a78d3d59c6cdbb06014bcefe3ed7eb0d929ffb1b06975df2caf7476f9beb3b0828be78fd766730668d0801732d8be21ba8d9d166007384999a8f4887b01534151e5d22a1f388be99412fc409018b587e1127177e34a3e470c3bc536da9f89345f0bcfdeb6b548be732d984d82c0a00aa359968ebc13aeb0ec170d86c230e35d478037aa4cc1441b186501323f5d9c90d00d133641314a03c3da85597bc23aaa10b56ecc43efc1035c69d76463cecb633a00e0043d39741a6e7b395eace3b1fbbbd5bbf288f7a788e80745a2e2bb0f2173a8b4f0f018e1ee0db6abadb25182adb757ee0fb68645c62892c43bdb5f66f04ddd49c26db1001d515393ea4ba786b0a887b03406e563b8bb6eec7130c2b74af11c301edb19242110177049afcfe3f07f8fb1ff429073573fd537ec93a14c0aaad71141afaac088093120176706b834e9776d305d9d5face0a7c273a646827ffc02c4f0fdf92192767ca3b1301b86fb4cf28dec81b269a278ed437302f10921d86fe16a4de0e0240f735ee8f5d1401e127033e641533f0ee99f0612c9e20c86e9c1974aada7e03af57ae81ef58c09b1501d789c8bba61eab50b62479a596b99f4268f8ae0a4c770e71ab75ed870b6ecda1160109ee69158b030e49dd6f79b65ea0dea62cca0df0163c7b08dc7379ac2e5265a91701ccc91d447ba4fa1d39e26b2e4c45cee12291790d0e54d95ce0c71ce798cc02de"
}
251 changes: 251 additions & 0 deletions tests/data/transaction/get_transaction_with_delegator_kind.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"api_version": "2.0.0",
"transaction": {
"Version1": {
"hash": "67594388afce12d027d2098f0bee6742702738647fb8d422d85f1b2c8b72192c",
"payload": {
"initiator_addr": {
"PublicKey": "015adadaecbd299c594821a548d755f51a5e2124fb17983f9afae019add32beb21"
},
"timestamp": "2024-12-04T14:54:15.400Z",
"ttl": "30m",
"chain_name": "casper-net-1",
"pricing_mode": {
"Fixed": {
"additional_computation_factor": 1,
"gas_price_tolerance": 1
}
},
"fields": {
"args": {
"Named": [
[
"delegator_purse",
{
"cl_type": "URef",
"bytes": "de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae9807",
"parsed": "uref-de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae98-007"
}
],
[
"amount",
{
"cl_type": "U512",
"bytes": "0500282e8cd1",
"parsed": "900000000000"
}
],
[
"validator",
{
"cl_type": "PublicKey",
"bytes": "01fed662dc7f1f7af43ad785ba07a8cc05b7a96f9ee69613cfde43bc56bec1140b",
"parsed": "01fed662dc7f1f7af43ad785ba07a8cc05b7a96f9ee69613cfde43bc56bec1140b"
}
]
]
},
"entry_point": {
"Custom": "delegate"
},
"scheduling": "Standard",
"target": {
"Stored": {
"id": {
"ByHash": "d39b360530484c6b3ed32e84a1198b368fe2bae3d5c9e8af6b0ae4d3eba73caa"
},
"runtime": "VmCasperV1",
"transferred_value": 0
}
}
}
},
"approvals": [
{
"signer": "015adadaecbd299c594821a548d755f51a5e2124fb17983f9afae019add32beb21",
"signature": "01dca399075db422c9d55976b050ef5cd221eae8a74b4dc0940d44d44c3c8743ca016f983491125e77f0e20a0aef2c1b7102c429141b5254536d453032a0f5c90a"
}
]
}
},
"execution_info": {
"block_hash": "c6d3dfe57580def4a7ccb0a2bacb294f4ef10dc392de2e7d845a8b76057f0f87",
"block_height": 11,
"execution_result": {
"Version2": {
"initiator": {
"PublicKey": "015adadaecbd299c594821a548d755f51a5e2124fb17983f9afae019add32beb21"
},
"error_message": null,
"limit": "50000000000",
"consumed": "2500000000",
"cost": "50000000000",
"transfers": [
{
"Version2": {
"transaction_hash": {
"Version1": "67594388afce12d027d2098f0bee6742702738647fb8d422d85f1b2c8b72192c"
},
"from": {
"AccountHash": "account-hash-cdda4c2ed893a1ba91274237ea101030adb7283ecaab2441941a7fe8100cc631"
},
"to": "account-hash-6174cf2e6f8fed1715c9a3bace9c50bfe572eecb763b0ed3f644532616452008",
"source": "uref-de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae98-002",
"target": "uref-94de0e38671dcf5f328134eecec56bb8349ad6ab575521ecb4ac6994eae9f638-007",
"amount": "900000000000",
"gas": "100000000",
"id": null
}
}
],
"size_estimate": 624,
"effects": [
{
"key": "balance-hold-01de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae9868292a9293010000",
"kind": {
"Write": {
"CLValue": {
"cl_type": "U512",
"bytes": "0500743ba40b",
"parsed": "50000000000"
}
}
}
},
{
"key": "hash-d39b360530484c6b3ed32e84a1198b368fe2bae3d5c9e8af6b0ae4d3eba73caa",
"kind": "Identity"
},
{
"key": "hash-8624f469c59e96f525abe85e9224440160d51ba1b46c641b947097fb8bfbbf06",
"kind": "Identity"
},
{
"key": "bid-addr-012f3fb80d362ad0a922f446915a259c9aaec9ba99292b3e50ff2359c458007309",
"kind": "Identity"
},
{
"key": "hash-2a9716d5916c2e581648cc0a030870af60df4ecbf891d179a334ee8ff1fd7b99",
"kind": "Identity"
},
{
"key": "hash-65b22b950127083ee0aa9e669c7c97534cd4825259fe480046043eb16c3146a5",
"kind": "Identity"
},
{
"key": "uref-94de0e38671dcf5f328134eecec56bb8349ad6ab575521ecb4ac6994eae9f638-000",
"kind": {
"Write": {
"CLValue": {
"cl_type": "Unit",
"bytes": "",
"parsed": null
}
}
}
},
{
"key": "balance-94de0e38671dcf5f328134eecec56bb8349ad6ab575521ecb4ac6994eae9f638",
"kind": {
"Write": {
"CLValue": {
"cl_type": "U512",
"bytes": "00",
"parsed": "0"
}
}
}
},
{
"key": "hash-2a9716d5916c2e581648cc0a030870af60df4ecbf891d179a334ee8ff1fd7b99",
"kind": "Identity"
},
{
"key": "hash-65b22b950127083ee0aa9e669c7c97534cd4825259fe480046043eb16c3146a5",
"kind": "Identity"
},
{
"key": "balance-hold-01de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae9868292a9293010000",
"kind": "Identity"
},
{
"key": "balance-de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae98",
"kind": {
"Write": {
"CLValue": {
"cl_type": "U512",
"bytes": "0e00d8d173385ac138938d44c64d31",
"parsed": "999999999999999999999100000000000"
}
}
}
},
{
"key": "balance-94de0e38671dcf5f328134eecec56bb8349ad6ab575521ecb4ac6994eae9f638",
"kind": {
"AddUInt512": "900000000000"
}
},
{
"key": "bid-addr-032f3fb80d362ad0a922f446915a259c9aaec9ba99292b3e50ff2359c458007309de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae98",
"kind": {
"Write": {
"BidKind": {
"Delegator": {
"delegator_kind": {
"Purse": "de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae98"
},
"staked_amount": "900000000000",
"bonding_purse": "uref-94de0e38671dcf5f328134eecec56bb8349ad6ab575521ecb4ac6994eae9f638-007",
"validator_public_key": "01fed662dc7f1f7af43ad785ba07a8cc05b7a96f9ee69613cfde43bc56bec1140b",
"vesting_schedule": null
}
}
}
}
},
{
"key": "balance-hold-01de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae9868292a9293010000",
"kind": {
"Prune": "balance-hold-01de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae9868292a9293010000"
}
},
{
"key": "balance-hold-00de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae9868292a9293010000",
"kind": {
"Write": {
"CLValue": {
"cl_type": "U512",
"bytes": "0500743ba40b",
"parsed": "50000000000"
}
}
}
},
{
"key": "bid-addr-012f3fb80d362ad0a922f446915a259c9aaec9ba99292b3e50ff2359c458007309",
"kind": "Identity"
},
{
"key": "bid-addr-042f3fb80d362ad0a922f446915a259c9aaec9ba99292b3e50ff2359c4580073090100000000000000",
"kind": {
"Write": {
"BidKind": {
"Credit": {
"validator_public_key": "01fed662dc7f1f7af43ad785ba07a8cc05b7a96f9ee69613cfde43bc56bec1140b",
"era_id": 1,
"amount": "50000000000"
}
}
}
}
}
]
}
}
}
}
}
1 change: 1 addition & 0 deletions tests/key/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func Test_Key_Constructor_fromString(t *testing.T) {
{"byte-code prefix", "byte-code-v1-wasm-1b1e23596b8c901a65a13e9d314ca2fff440e69df42f226a76a9bbfbb90df1fa", "byte-code-v1-wasm-1b1e23596b8c901a65a13e9d314ca2fff440e69df42f226a76a9bbfbb90df1fa"},
{"bid-addr- prefix", "bid-addr-01da3cd8cc4c8f34e7731583e67ddc211ff9b5c3f2c52640582415c2cce9315b2a", "bid-addr-01da3cd8cc4c8f34e7731583e67ddc211ff9b5c3f2c52640582415c2cce9315b2a"},
{"bid-addr- prefix", "bid-addr-0494f1805abf61fac1b206d35773f1d1e71be2a162b58acd29fbca6ea5e8e73bedea00000000000000", "bid-addr-0494f1805abf61fac1b206d35773f1d1e71be2a162b58acd29fbca6ea5e8e73bedea00000000000000"},
{"bid-addr- prefix", "bid-addr-032f3fb80d362ad0a922f446915a259c9aaec9ba99292b3e50ff2359c458007309de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae98", "bid-addr-032f3fb80d362ad0a922f446915a259c9aaec9ba99292b3e50ff2359c458007309de0ef381c12dc842e0872453d35aa4b49fa488c0427e68b7dd5ac63e151eae98"},
{"message-topic prefix", "message-topic-entity-contract-55d4a6915291da12afded37fa5bc01f0803a2f0faf6acb7ec4c7ca6ab76f3330-5721a6d9d7a9afe5dfdb35276fb823bed0f825350e4d865a5ec0110c380de4e1", "message-topic-entity-contract-55d4a6915291da12afded37fa5bc01f0803a2f0faf6acb7ec4c7ca6ab76f3330-5721a6d9d7a9afe5dfdb35276fb823bed0f825350e4d865a5ec0110c380de4e1"},
{"message-system prefix", "message-topic-entity-system-55d4a6915291da12afded37fa5bc01f0803a2f0faf6acb7ec4c7ca6ab76f3330-5721a6d9d7a9afe5dfdb35276fb823bed0f825350e4d865a5ec0110c380de4e1", "message-topic-entity-system-55d4a6915291da12afded37fa5bc01f0803a2f0faf6acb7ec4c7ca6ab76f3330-5721a6d9d7a9afe5dfdb35276fb823bed0f825350e4d865a5ec0110c380de4e1"},
{"message-account prefix", "message-topic-entity-account-55d4a6915291da12afded37fa5bc01f0803a2f0faf6acb7ec4c7ca6ab76f3330-5721a6d9d7a9afe5dfdb35276fb823bed0f825350e4d865a5ec0110c380de4e1", "message-topic-entity-account-55d4a6915291da12afded37fa5bc01f0803a2f0faf6acb7ec4c7ca6ab76f3330-5721a6d9d7a9afe5dfdb35276fb823bed0f825350e4d865a5ec0110c380de4e1"},
Expand Down
3 changes: 3 additions & 0 deletions tests/rpc/rpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ func Test_DefaultClient_GetTransaction_Example(t *testing.T) {
{
filePath: "../data/transaction/get_transaction_native_target.json",
},
{
filePath: "../data/transaction/get_transaction_with_delegator_kind.json",
},
}
for _, tt := range tests {
t.Run("GetTransaction", func(t *testing.T) {
Expand Down
15 changes: 14 additions & 1 deletion tests/types/era_summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@ func Test_EraSummary_MarshalUnmarshal_ShouldReturnSameResult(t *testing.T) {
tests := []struct {
name string
fixturePath string
isPurse bool
}{
{
"V1 EraSummary",
"../data/era/era_summary_example.json",
false,
},
{
"V2 EraSummary",
"../data/era/era_summary_v2.json",
false,
},
{
"V2 EraSummary",
"../data/era/era_summary_v2_delegator_kind_purse.json",
true,
},
}
for _, test := range tests {
Expand All @@ -35,7 +43,12 @@ func Test_EraSummary_MarshalUnmarshal_ShouldReturnSameResult(t *testing.T) {

for _, summary := range era.StoredValue.EraInfo.SeigniorageAllocations {
if summary.Delegator != nil {
assert.NotNil(t, summary.Delegator.DelegatorKind.PublicKey)
if !test.isPurse {
assert.NotNil(t, summary.Delegator.DelegatorKind.PublicKey)
}
if test.isPurse {
assert.NotNil(t, summary.Delegator.DelegatorKind.Purse)
}
}
}
})
Expand Down
Loading
Loading