Skip to content

Commit

Permalink
bridge-hub-kusama: Update tests to use RelayTreasuryPalletAccount con…
Browse files Browse the repository at this point in the history
…stant
  • Loading branch information
vgeddes committed Mar 25, 2024
1 parent c842fca commit 9d62889
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
use asset_hub_kusama_runtime::xcm_config::bridging::to_ethereum::{
BridgeHubEthereumBaseFee, EthereumNetwork,
use asset_hub_kusama_runtime::xcm_config::{
RelayTreasuryPalletAccount,
bridging::to_ethereum::{
BridgeHubEthereumBaseFee, EthereumNetwork
}
};
use bp_bridge_hub_kusama::snowbridge::CreateAssetCall;
use bridge_hub_kusama_runtime::{
Expand Down Expand Up @@ -51,8 +54,6 @@ use system_parachains_constants::kusama::currency::UNITS;

const INITIAL_FUND: u128 = 5_000_000_000 * KUSAMA_ED;
const CHAIN_ID: u64 = 1;
const TREASURY_ACCOUNT: [u8; 32] =
hex!("da5026b2e34b876343bd6becae58eb5af71ec727633bfb972641fa7a89ff4988");
const WETH: [u8; 20] = hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d");
const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EBD0D8D2333700e");
const GATEWAY_ADDRESS: [u8; 20] = hex!("EDa338E4dC46038493b885327842fD3E301CaB39");
Expand Down Expand Up @@ -440,7 +441,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {

BridgeHubKusama::fund_accounts(vec![
(assethub_sovereign.clone(), INITIAL_FUND),
(TREASURY_ACCOUNT.into(), INITIAL_FUND),
(RelayTreasuryPalletAccount::get(), INITIAL_FUND),
]);
AssetHubKusama::fund_accounts(vec![
(AssetHubPolkadotReceiver::get(), INITIAL_FUND),
Expand Down Expand Up @@ -505,7 +506,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {

// check treasury account balance on BH before
let treasury_account_before = BridgeHubKusama::execute_with(|| {
<<BridgeHubKusama as BridgeHubKusamaPallet>::Balances as frame_support::traits::fungible::Inspect<_>>::balance(&TREASURY_ACCOUNT.into())
<<BridgeHubKusama as BridgeHubKusamaPallet>::Balances as frame_support::traits::fungible::Inspect<_>>::balance(&RelayTreasuryPalletAccount::get())
});

AssetHubKusama::execute_with(|| {
Expand Down Expand Up @@ -573,7 +574,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {
);

// check treasury account balance on BH after (should receive some fees)
let treasury_account_after = <<BridgeHubKusama as BridgeHubKusamaPallet>::Balances as frame_support::traits::fungible::Inspect<_>>::balance(&TREASURY_ACCOUNT.into());
let treasury_account_after = <<BridgeHubKusama as BridgeHubKusamaPallet>::Balances as frame_support::traits::fungible::Inspect<_>>::balance(&RelayTreasuryPalletAccount::get());
let local_fee = treasury_account_after - treasury_account_before;

let events = BridgeHubKusama::events();
Expand All @@ -582,7 +583,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {
events.iter().any(|event| matches!(
event,
RuntimeEvent::Balances(pallet_balances::Event::Minted { who, amount })
if *who == TREASURY_ACCOUNT.into() && *amount == local_fee
if *who == RelayTreasuryPalletAccount::get() && *amount == local_fee
)),
"Snowbridge sovereign takes local fee."
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use crate::{
xcm_config, xcm_config::UniversalLocation, Balances, EthereumInboundQueue,
xcm_config, xcm_config::{UniversalLocation, RelayTreasuryPalletAccount}, Balances, EthereumInboundQueue,
EthereumOutboundQueue, EthereumSystem, MessageQueue, Runtime, RuntimeEvent, TransactionByteFee,
TreasuryAccount,
};
pub use bp_bridge_hub_kusama::snowbridge::EthereumNetwork;
use bp_bridge_hub_kusama::snowbridge::{CreateAssetCall, InboundQueuePalletInstance, Parameters};
Expand Down Expand Up @@ -157,7 +156,7 @@ impl snowbridge_pallet_system::Config for Runtime {
type OutboundQueue = EthereumOutboundQueue;
type SiblingOrigin = EnsureXcm<AllowSiblingsOnly>;
type AgentIdOf = snowbridge_core::AgentIdOf;
type TreasuryAccount = TreasuryAccount;
type TreasuryAccount = RelayTreasuryPalletAccount;
type Token = Balances;
type WeightInfo = crate::weights::snowbridge_pallet_system::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
Expand All @@ -168,7 +167,7 @@ impl snowbridge_pallet_system::Config for Runtime {

#[cfg(feature = "runtime-benchmarks")]
pub mod benchmark_helpers {
use super::{EthereumGatewayAddress, Runtime, TreasuryAccount};
use super::{EthereumGatewayAddress, Runtime, RelayTreasuryPalletAccount};
use crate::{Balances, EthereumBeaconClient, ExistentialDeposit, RuntimeOrigin};
use codec::Encode;
use frame_support::traits::fungible;
Expand Down Expand Up @@ -205,7 +204,7 @@ pub mod benchmark_helpers {
fn make_xcm_origin(location: Location) -> RuntimeOrigin {
// Drip ED to the `TreasuryAccount`
<Balances as fungible::Mutate<_>>::set_balance(
&TreasuryAccount::get(),
&RelayTreasuryPalletAccount::get(),
ExistentialDeposit::get(),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl snowbridge_pallet_system::Config for Runtime {

#[cfg(feature = "runtime-benchmarks")]
pub mod benchmark_helpers {
use super::{EthereumGatewayAddress, Runtime, TreasuryAccount};
use super::{EthereumGatewayAddress, Runtime, RelayTreasuryPalletAccount};
use crate::{Balances, EthereumBeaconClient, ExistentialDeposit, RuntimeOrigin};
use codec::Encode;
use frame_support::traits::fungible;
Expand Down Expand Up @@ -204,7 +204,7 @@ pub mod benchmark_helpers {
fn make_xcm_origin(location: Location) -> RuntimeOrigin {
// Drip ED to the `TreasuryAccount`
<Balances as fungible::Mutate<_>>::set_balance(
&TreasuryAccount::get(),
&RelayTreasuryPalletAccount::get(),
ExistentialDeposit::get(),
);

Expand Down

0 comments on commit 9d62889

Please sign in to comment.