diff --git a/toolkit/offchain/src/update_governance/mod.rs b/toolkit/offchain/src/update_governance/mod.rs index 07e0df6a9..495fa233e 100644 --- a/toolkit/offchain/src/update_governance/mod.rs +++ b/toolkit/offchain/src/update_governance/mod.rs @@ -114,7 +114,7 @@ fn update_governance_tx( let mut tx_builder = TransactionBuilder::new(&config); tx_builder.add_mint_one_script_token_using_reference_script( - &multi_sig_policy, + &governance_data.policy_script, &governance_data.utxo_id_as_tx_input(), &mint_ex_units, )?; diff --git a/toolkit/offchain/src/update_governance/test.rs b/toolkit/offchain/src/update_governance/test.rs index 30f1decf4..103748c60 100644 --- a/toolkit/offchain/src/update_governance/test.rs +++ b/toolkit/offchain/src/update_governance/test.rs @@ -97,7 +97,7 @@ fn governance_data() -> GovernanceData { fn new_governance_authority() -> MainchainAddressHash { MainchainAddressHash(hex_literal::hex!( - "76da17b2e3371ab7ca88ce0500441149f03cc5091009f99c99c080d9" + "84ba05c28879b299a8377e62128adc7a0e0df3ac438ff95efc7c8443" )) } @@ -110,7 +110,8 @@ fn spend_ex_units() -> ExUnits { } fn multisig_policy_hash() -> [u8; 28] { - hex!("f298532e5be52f55bb60602ada0e4b7038569ec728fbe03c7254d2b9") + // important: this is the hash of the multisig policy parametrized with the *old* authority + hex!("a646474b8f5431261506b6c273d307c7569a4eb6c96b42dd4a29520a") } fn version_oracle_validator_address() -> Address { diff --git a/toolkit/offchain/src/update_governance/test_values.rs b/toolkit/offchain/src/update_governance/test_values.rs index a5d7411ba..ff7ca9516 100644 --- a/toolkit/offchain/src/update_governance/test_values.rs +++ b/toolkit/offchain/src/update_governance/test_values.rs @@ -35,17 +35,17 @@ pub(crate) fn test_update_governance_tx() -> serde_json::Value { "Data": "{\"list\":[{\"int\":32},{\"bytes\":\"c11dee532646a9b226aac75f77ea7ae5fba9270674327c882794701e\"}]}" }, "script_ref": { - "PlutusScript": "5901d30100003323322323232323322323232222323232532323355333573466e20cc8c8c88c008004c058894cd4004400c884cc018008c010004c04488004c04088008c01000400840304034403c4c02d24010350543500300d37586ae84008dd69aba1357440026eb0014c040894cd400440448c884c8cd40514cd4c00cc04cc030dd6198009a9803998009a980380411000a40004400290080a400429000180300119112999ab9a33710002900009807a490350543600133003001002301522253350011300f49103505437002215333573466e1d20000041002133005337020089001000980991299a8008806910a999ab9a3371e00a6eb800840404c0100048c8cc8848cc00400c008d55ce80098031aab9e00137540026016446666aae7c00480348cd4030d5d080118019aba2002498c02888cccd55cf8009006119a8059aba100230033574400493119319ab9c00100512200212200130062233335573e0024010466a00e6eb8d5d080118019aba20020031200123300122337000040029000180191299a800880211099a802801180200089100109109119800802001919180080091198019801001000a61239f9f581c76da17b2e3371ab7ca88ce0500441149f03cc5091009f99c99c080d9ff01ff0001" + "PlutusScript": "5901d30100003323322323232323322323232222323232532323355333573466e20cc8c8c88c008004c058894cd4004400c884cc018008c010004c04488004c04088008c01000400840304034403c4c02d24010350543500300d37586ae84008dd69aba1357440026eb0014c040894cd400440448c884c8cd40514cd4c00cc04cc030dd6198009a9803998009a980380411000a40004400290080a400429000180300119112999ab9a33710002900009807a490350543600133003001002301522253350011300f49103505437002215333573466e1d20000041002133005337020089001000980991299a8008806910a999ab9a3371e00a6eb800840404c0100048c8cc8848cc00400c008d55ce80098031aab9e00137540026016446666aae7c00480348cd4030d5d080118019aba2002498c02888cccd55cf8009006119a8059aba100230033574400493119319ab9c00100512200212200130062233335573e0024010466a00e6eb8d5d080118019aba20020031200123300122337000040029000180191299a800880211099a802801180200089100109109119800802001919180080091198019801001000a61239f9f581c84ba05c28879b299a8377e62128adc7a0e0df3ac438ff95efc7c8443ff01ff0001" } }, { // change returned "address": "addr_test1vpmd59ajuvm34d723r8q2qzyz9ylq0x9pygqn7vun8qgpkgs7y5hw", "amount": { - "coin": "9922268377", + "coin": "9922275427", // minted governance token "multiasset": { - "f298532e5be52f55bb60602ada0e4b7038569ec728fbe03c7254d2b9": { + "a646474b8f5431261506b6c273d307c7569a4eb6c96b42dd4a29520a": { "": "1" } } @@ -54,7 +54,7 @@ pub(crate) fn test_update_governance_tx() -> serde_json::Value { "script_ref": null } ], - "fee": "304797", + "fee": "297747", "ttl": null, "certs": null, "withdrawals": null, @@ -64,7 +64,7 @@ pub(crate) fn test_update_governance_tx() -> serde_json::Value { "mint": [ [ // governance token - "f298532e5be52f55bb60602ada0e4b7038569ec728fbe03c7254d2b9", + "a646474b8f5431261506b6c273d307c7569a4eb6c96b42dd4a29520a", { "": "1" } @@ -84,13 +84,13 @@ pub(crate) fn test_update_governance_tx() -> serde_json::Value { "collateral_return": { "address": "addr_test1vpmd59ajuvm34d723r8q2qzyz9ylq0x9pygqn7vun8qgpkgs7y5hw", "amount": { - "coin": "9922488741", + "coin": "9922499316", "multiasset": null }, "plutus_data": null, "script_ref": null }, - "total_collateral": "457196", + "total_collateral": "446621", "reference_inputs": null, "voting_procedures": null, "voting_proposals": null, diff --git a/toolkit/offchain/tests/integration_tests.rs b/toolkit/offchain/tests/integration_tests.rs index 0ae841982..e00938c37 100644 --- a/toolkit/offchain/tests/integration_tests.rs +++ b/toolkit/offchain/tests/integration_tests.rs @@ -60,23 +60,14 @@ const REWARDS_TOKEN_POLICY_ID: PolicyId = const REWARDS_TOKEN_ASSET_NAME_STR: &str = "5043526f636b73"; #[tokio::test] -async fn init_goveranance() { - let image = GenericImage::new(TEST_IMAGE, TEST_IMAGE_TAG); - let client = Cli::default(); - let container = client.run(image); - let client = initialize(&container).await; - let _ = run_init_goveranance(&client).await; - () -} - -#[tokio::test] -async fn update_governance() { +async fn governance_flow() { let image = GenericImage::new(TEST_IMAGE, TEST_IMAGE_TAG); let client = Cli::default(); let container = client.run(image); let client = initialize(&container).await; let genesis_utxo = run_init_goveranance(&client).await; let _ = run_update_goveranance(&client, genesis_utxo).await; + assert!(run_upsert_d_param(genesis_utxo, 0, 1, EVE_PAYMENT_KEY, &client).await.is_some()); } #[tokio::test] @@ -86,9 +77,15 @@ async fn upsert_d_param() { let container = client.run(image); let client = initialize(&container).await; let genesis_utxo = run_init_goveranance(&client).await; - assert!(run_upsert_d_param(genesis_utxo, 0, 1, &client).await.is_some()); - assert!(run_upsert_d_param(genesis_utxo, 0, 1, &client).await.is_none()); - assert!(run_upsert_d_param(genesis_utxo, 1, 1, &client).await.is_some()) + assert!(run_upsert_d_param(genesis_utxo, 0, 1, GOVERNANCE_AUTHORITY_PAYMENT_KEY, &client) + .await + .is_some()); + assert!(run_upsert_d_param(genesis_utxo, 0, 1, GOVERNANCE_AUTHORITY_PAYMENT_KEY, &client) + .await + .is_none()); + assert!(run_upsert_d_param(genesis_utxo, 1, 1, GOVERNANCE_AUTHORITY_PAYMENT_KEY, &client) + .await + .is_some()) } #[tokio::test] @@ -201,7 +198,7 @@ async fn run_update_goveranance< genesis_utxo: UtxoId, ) -> () { let _ = update_governance::run_update_governance( - GOVERNANCE_AUTHORITY, + EVE_PUBLIC_KEY_HASH, GOVERNANCE_AUTHORITY_PAYMENT_KEY, genesis_utxo, client, @@ -217,12 +214,13 @@ async fn run_upsert_d_param< genesis_utxo: UtxoId, num_permissioned_candidates: u16, num_registered_candidates: u16, + pkey: MainchainPrivateKey, client: &T, ) -> Option { let tx_hash = d_param::upsert_d_param( genesis_utxo, &DParameter { num_permissioned_candidates, num_registered_candidates }, - GOVERNANCE_AUTHORITY_PAYMENT_KEY.0, + pkey.0, client, ) .await