Skip to content

Commit

Permalink
Start with smoketest for transact.
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Aug 11, 2023
1 parent 0068613 commit c9ce72b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions contracts/src/DeployScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {AgentExecutor} from "./AgentExecutor.sol";
import {ParaID, Config} from "./Types.sol";
import {SafeNativeTransfer} from "./utils/SafeTransfer.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {HelloWorld} from "../test/mocks/HelloWorld.sol";

contract DeployScript is Script {
using SafeNativeTransfer for address payable;
Expand Down Expand Up @@ -81,6 +82,7 @@ contract DeployScript is Script {
payable(assetHubAgent).safeNativeTransfer(initialDeposit);

new GatewayUpgradeMock();
new HelloWorld();

vm.stopBroadcast();
}
Expand Down
12 changes: 12 additions & 0 deletions contracts/test/mocks/HelloWorld.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]>
pragma solidity ^0.8.0;

contract HelloWorld {
event SaidHello(string message);

function sayHello(string memory _text) public {
string memory fullMessage = string(abi.encodePacked("Hello world ", _text));
emit SaidHello(fullMessage);
}
}
6 changes: 1 addition & 5 deletions parachain/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ enum XcmConverterError {
BeneficiaryResolutionFailed,
AssetResolutionFailed,
SetTopicExpected,
UnknownCommand
}

struct XcmConverter<'a, Call> {
Expand Down Expand Up @@ -313,8 +312,6 @@ impl<'a, Call> XcmConverter<'a, Call> {
}

fn transact_message(&mut self) -> Result<AgentExecuteCommand, XcmConverterError> {
use XcmConverterError::*;

Ok(AgentExecuteCommand::Transact {
target: Default::default(),
payload: vec![],
Expand All @@ -331,7 +328,6 @@ impl<'a, Call> XcmConverter<'a, Call> {
mod tests {
use frame_support::parameter_types;
use hex_literal::hex;
use xcm::DoubleEncoded;
use snowbridge_core::outbound::{MessageHash, SubmitError};

use super::*;
Expand Down Expand Up @@ -780,7 +776,7 @@ mod tests {
Transact{
origin_kind: OriginKind::Native,
require_weight_at_most: Default::default(),
call: Default::default(),// TODO fix
call: vec![].into(),
},
SetTopic([0; 32]),
]
Expand Down
2 changes: 1 addition & 1 deletion smoketest/make-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mkdir -p src/contracts

# Generate Rust bindings for contracts
forge bind --module --overwrite \
--select 'IGateway|WETH9|GatewayUpgradeMock' \
--select 'IGateway|WETH9|GatewayUpgradeMock|HelloWorld' \
--bindings-path src/contracts \
--root ../contracts

Expand Down
5 changes: 4 additions & 1 deletion smoketest/tests/transact_polkadot_to_ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use snowbridge_smoketest::contracts::i_gateway::InboundMessageDispatchedFilter;
use snowbridge_smoketest::helper::*;
use snowbridge_smoketest::parachains::bridgehub::api::ethereum_control::events::TransferNativeFromAgent;
use snowbridge_smoketest::xcm::construct_xcm_message;
use hex_literal::hex;

const HELLO_WORLD_CONTRACT: [u8; 20] = hex!("EE9170ABFbf9421Ad6DD07F6BDec9D89F2B581E0");

#[tokio::test]
async fn transact() {
Expand All @@ -27,7 +30,7 @@ async fn transact() {
let message = construct_xcm_message(
construct_transact_call(
&test_clients.bridge_hub_client,
ETHEREUM_ADDRESS.into(), // TODO TARGET ARBITRARY CONTRACT
HELLO_WORLD_CONTRACT.into(),
vec![], // TODO CONTRACT BYTES HERE
)
.await
Expand Down

0 comments on commit c9ce72b

Please sign in to comment.