Skip to content

Commit

Permalink
Merge pull request #96 from paritytech/muharem-opengov-fellowship
Browse files Browse the repository at this point in the history
Polkadot Opengov tests
  • Loading branch information
NachoPal committed Jul 20, 2023
2 parents e94e025 + 8655bef commit d880471
Show file tree
Hide file tree
Showing 11 changed files with 890 additions and 90 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules
!/bin/README.md
/logs
/*.json
*.log
*.log
._*
112 changes: 98 additions & 14 deletions examples/collectives-polkadot/0_xcm/0_init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ settings:
collectives_parachain: &collectives_parachain
wsPort: 9710
paraId: &cp_id 1001
assethub_parachain: &assethub_parachain
wsPort: 9810
paraId: &sp_id 1000
variables:
xcm_version: &xcm_version 3
weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] }
xcm_version: &xcm_version '3'
chains:
accounts:
alice_signer: &alice_signer //Alice
decodedCalls:
cp_force_xcm_version:
ap_force_xcm_version:
chain: *collectives_parachain
pallet: polkadotXcm
call: forceXcmVersion
Expand Down Expand Up @@ -49,9 +51,13 @@ tests:
]
events:
- name: sudo.Sudid
result: { sudoResult: Ok }
attributes:
- type: Result<Null, SpRuntimeDispatchError>
value: Ok
- name: xcmPallet.SupportedVersionChanged
result: [{ parents: 0, interior: { X1: { Parachain: *cp_id }}}, *xcm_version ]
attributes:
- type: u32
value: *xcm_version
- extrinsics: # Collectives Parachain sets supported version for Relay Chain through it
- chain: *relay_chain
signer: *alice_signer
Expand All @@ -64,7 +70,7 @@ tests:
v3: [ # message
{
UnpaidExecution: {
weightLimit: {
weightLimit: {
limited: {
refTime: 2200000000, # 2_200_000_000
proofSize: 200000, # 200_000
Expand All @@ -76,25 +82,103 @@ tests:
Transact: {
originKind: Superuser,
requireWeightAtMost: {
refTime: 200000000, # 200_000_000
refTime: 200000000, # 200_000_000
proofSize: 0,
},
call: $cp_force_xcm_version
call: $ap_force_xcm_version
}
}
]
}
]
events:
- name: sudo.Sudid
result: { sudoResult: Ok }
attributes:
- type: Result<Null, SpRuntimeDispatchError>
value: Ok
- name: xcmPallet.Sent
- name: polkadotXcm.SupportedVersionChanged
chain: *collectives_parachain
attributes:
- type: u32
value: *xcm_version
- name: dmpQueue.ExecutedDownward
chain: *collectives_parachain
threshold: *weight_threshold
result: {
outcome: { Complete: { refTime: '2,200,000,000', proofSize: 0 }}
attributes:
- type: XcmV3TraitsOutcome
xcmOutcome: Complete
- extrinsics: # Relay Chain sets supported version for AssetHub Parachain
- chain: *relay_chain
sudo: true
signer: *alice_signer
pallet: xcmPallet
call: forceXcmVersion
args: [
{ # location
parents: 0,
interior: {
X1: {
Parachain: *sp_id
}
}
},
*xcm_version
]
events:
- name: sudo.Sudid
attributes:
- type: Result<Null, SpRuntimeDispatchError>
value: Ok
- name: xcmPallet.SupportedVersionChanged
attributes:
- type: u32
value: *xcm_version
- extrinsics: # AssetHub Parachain sets supported version for Relay Chain through it
- chain: *relay_chain
signer: *alice_signer
sudo: true
pallet: xcmPallet
call: send
args: [
{ v3: { 0, interior: { x1: { parachain: *sp_id }}}}, # destination
{
v3: [ # message
{
UnpaidExecution: {
weightLimit: {
limited: {
refTime: 2200000000, # 2_200_000_000
proofSize: 200000, # 200_000
},
}
}
},
{
Transact: {
originKind: Superuser,
requireWeightAtMost: {
refTime: 200000000, # 200_000_000
proofSize: 0,
},
call: $ap_force_xcm_version
}
}
]
}
]
events:
- name: sudo.Sudid
attributes:
- type: Result<Null, SpRuntimeDispatchError>
value: Ok
- name: xcmPallet.Sent
- name: polkadotXcm.SupportedVersionChanged
chain: *collectives_parachain
result: [{ parents: 1, interior: Here }, *xcm_version ]
chain: *assethub_parachain
attributes:
- type: u32
value: *xcm_version
- name: dmpQueue.ExecutedDownward
chain: *assethub_parachain
attributes:
- type: XcmV3TraitsOutcome
xcmOutcome: Complete
68 changes: 39 additions & 29 deletions examples/collectives-polkadot/0_xcm/1_teleport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ settings:
wsPort: 9710
paraId: &cp_id 1001
variables:
weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] }
accounts:
alice_signer: &acc_alice_signer //Alice
alice_account32: &acc_alice_acc32 '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
alice_ss58: &acc_alice_ss58 '15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5'
checking_account: &checking_account '13UVJyLnbVp9x5XDyJv8g8r3UddNwBrdaH7AADCmw9XQWvYW'


tests:
- name: Teleport assets from Relay Chain to Collectives Parachain successful.
Expand Down Expand Up @@ -42,32 +39,33 @@ tests:
args: [
{ v3: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination
{ v3: { parents: 0, interior: { x1: { accountId32: { id: *acc_alice_acc32 }}}}}, # beneficiary
{
v3: [
# {
{
v3: [
# {
# # TODO use a separate Assets to pay a fee, to receive an exact amount of assets on beneficiary account.
# # a call with two assets fails with an error right now.
# id: { concrete: { 0, interior: { here: true }}},
# fun: { fungible: 1000000000000 } # 1_000_000_000_000
# id: { concrete: { 0, interior: { here: true }}},
# fun: { fungible: 1000000000000 } # 1_000_000_000_000
# },
{
id: { concrete: { 0, interior: { here: true }}},
{
id: { concrete: { 0, interior: { here: true }}},
fun: { fungible: 20000000000000 } # 20_000_000_000_000
}
]
]
}, # assets
0, # feeAssetItem
]
events:
- name: xcmPallet.Attempted
threshold: *weight_threshold
result: [{ Complete: { refTime: '3,000,000,000', proofSize: 0 }}]
chain: *relay_chain
attributes:
- type: XcmV3TraitsOutcome
xcmOutcome: Complete
- name: dmpQueue.ExecutedDownward
chain: *collectives_parachain
threshold: *weight_threshold
result: {
outcome: { Complete: { refTime: '4,000,000,000', proofSize: 0 }}
}
attributes:
- type: XcmV3TraitsOutcome
xcmOutcome: Complete
- queries:
balance_rc_alice_2:
chain: *relay_chain
Expand Down Expand Up @@ -111,29 +109,41 @@ tests:
args: [
{ v3: { parents: 1, interior: { here: true }}}, # destination
{ v3: { parents: 0, interior: { x1: { accountId32: { id: *acc_alice_acc32 }}}}}, # beneficiary
{
v3: [
{
id: { concrete: { parents: 1, interior: { here: true }}},
{
v3: [
{
id: { concrete: { parents: 1, interior: { here: true }}},
fun: { fungible: 10000000000000 } # 10_000_000_000_000
}
]
]
}, # assets
0, # feeAssetItem
]
events:
- name: balances.Withdraw
result: { who: *acc_alice_ss58, amount: 10000000000000 }
attributes:
- type: AccountId32
key: who
value: *acc_alice_ss58
- type: u128
key: amount
value: 10000000000000
- name: polkadotXcm.Attempted
threshold: *weight_threshold
result: [{ Complete: { refTime: '3,000,000,000', proofSize: 0 }}]
attributes:
- type: XcmV3TraitsOutcome
xcmOutcome: Complete
- name: balances.Withdraw
chain: *relay_chain
result: { who: *checking_account, amount: 10000000000000 } # amount received and withdrawn from registry account
- name: ump.ExecutedUpward
attributes:
- type: u128
key: amount
value: 10000000000000 # amount received and withdrawn from registry account
- name: messageQueue.Processed
chain: *relay_chain
threshold: *weight_threshold
result: [{ Complete: { refTime: '4,000,000,000', proofSize: 0 }}]
attributes:
- type: bool
key: success
value: true
- queries:
balance_rc_alice_3:
chain: *relay_chain
Expand Down
55 changes: 38 additions & 17 deletions examples/collectives-polkadot/0_xcm/2_reserve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ settings:
wsPort: 9710
paraId: &cp_id 1001
variables:
weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] }
chains:
accounts:
alice_signer: &alice_signer //Alice
alice_account32: &alice_acc32 '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
alice_ss58: &acc_alice_ss58 '15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5'

tests:
- name: Reserve assets from Relay Chain to Collectives Parachain fails
Expand All @@ -26,28 +26,49 @@ tests:
args: [
{ v3: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination
{ v3: { parents: 0, interior: { x1: { accountId32: { id: *alice_acc32 }}}}}, # beneficiary
{
v3: [
{
id: { concrete: { 0, interior: { here: true }}},
{
v3: [
{
id: { concrete: { 0, interior: { here: true }}},
fun: { fungible: 20000000000000 } # 20_000_000_000_000
}
]
]
}, # assets
0, # feeAssetItem
]
events:
- name: xcmPallet.Attempted
threshold: *weight_threshold
result: [{ Complete: { refTime: '2,000,000,000', proofSize: 0 }}]
chain: *relay_chain
attributes:
- type: XcmV3TraitsOutcome
xcmOutcome: Complete
- name: dmpQueue.ExecutedDownward
chain: *collectives_parachain
threshold: *weight_threshold
result: {
outcome: {
Incomplete: [
{ refTime: '1,000,000,000', proofSize: 0 },
UntrustedReserveLocation
]
}
}
attributes:
- type: XcmV3TraitsOutcome
xcmOutcome: Incomplete

# Fails with the message - "RpcError: 1010: Invalid Transaction: Transaction would exhaust the block limits"
# Because of the u64::MAX weight set fot the extrinsic to disable it.
# The test tool does not allow to assert such a fail.

# - name: Reserve assets from Collectives Parachain to Relay Chain fails
# actions:
# - extrinsics:
# - chain: *collectives_parachain
# signer: *alice_signer
# pallet: polkadotXcm
# call: reserveTransferAssets
# args: [
# { v3: { parents: 1, interior: { here: true }}}, # destination
# { v3: { parents: 0, interior: { x1: { accountId32: { id: *alice_acc32 }}}}}, # beneficiary
# {
# v3: [
# {
# id: { concrete: { parents: 1, interior: { here: true }}},
# fun: { fungible: 10000000000000 } # 10_000_000_000_000
# }
# ]
# }, # assets
# 0, # feeAssetItem
# ]
Loading

0 comments on commit d880471

Please sign in to comment.