Skip to content

Commit

Permalink
chore: integrate with latest relayer (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoticTempest authored Apr 26, 2023
1 parent 16c0692 commit 3181018
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: 'near/pagoda-relayer-rs-fastauth'
ref: 'daniyar/custom-entrypoint'
path: 'relayer'
repository: "near/pagoda-relayer-rs-fastauth"
ref: "mpc/entrypoint"
path: "relayer"
ssh-key: ${{ secrets.RELAYER_DEPLOY_SSH_KEY }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Running integration tests requires you to have relayer docker image present on y

```BASH
# TODO: upstream these changes
git clone -b daniyar/custom-entrypoint git@github.com:near/pagoda-relayer-rs-fastauth.git
git clone -b mpc/entrypoint git@github.com:near/pagoda-relayer-rs-fastauth.git
docker build pagoda-relayer-rs-fastauth -t pagoda-relayer-rs-fastauth
```

Expand Down
8 changes: 8 additions & 0 deletions integration-tests/tests/docker/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Relayer {
}

impl Relayer {
#[allow(clippy::too_many_arguments)] // TODO: fix later
pub async fn start(
docker: &Docker,
network: &str,
Expand All @@ -23,6 +24,9 @@ impl Relayer {
relayer_account_id: &AccountId,
relayer_account_sk: &SecretKey,
creator_account_id: &AccountId,
social_db_id: &AccountId,
social_account_id: &AccountId,
social_account_sk: &SecretKey,
) -> anyhow::Result<Self> {
super::create_network(docker, network).await?;
let web_port = portpicker::pick_unused_port().expect("no free ports");
Expand Down Expand Up @@ -61,6 +65,10 @@ impl Relayer {
format!("PUBLIC_KEY={}", relayer_account_sk.public_key()),
format!("PRIVATE_KEY={}", relayer_account_sk),
format!("RELAYER_WHITELISTED_CONTRACT={}", creator_account_id),
format!("CUSTOM_SOCIAL_DB_ID={}", social_db_id),
format!("STORAGE_ACCOUNT_ID={}", social_account_id),
format!("STORAGE_PUBLIC_KEY={}", social_account_sk.public_key()),
format!("STORAGE_PRIVATE_KEY={}", social_account_sk),
]),
..Default::default()
};
Expand Down
27 changes: 27 additions & 0 deletions integration-tests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ where

let (pk_set, sk_shares) = mpc_recovery::generate(nodes);
let worker = workspaces::sandbox().await?;
let social_db = worker
.import_contract(&"social.near".parse()?, &workspaces::mainnet().await?)
.transact()
.await?;
social_db
.call("new")
.max_gas()
.transact()
.await?
.into_result()?;

let near_root_account = worker.root_account()?;
near_root_account
.deploy(include_bytes!("../linkdrop.wasm"))
Expand All @@ -59,6 +70,8 @@ where
.into_result()?;
let (relayer_account_id, relayer_account_sk) = create_account(&worker).await?;
let (creator_account_id, creator_account_sk) = create_account(&worker).await?;
let (social_account_id, social_account_sk) = create_account(&worker).await?;
up_funds_for_account(&worker, &social_account_id).await?;

let near_rpc = format!("http://{HOST_MACHINE_FROM_DOCKER}:{}", worker.rpc_port());
let datastore = Datastore::start(&docker, NETWORK, GCP_PROJECT_ID).await?;
Expand All @@ -71,8 +84,12 @@ where
&relayer_account_id,
&relayer_account_sk,
&creator_account_id,
social_db.id(),
&social_account_id,
&social_account_sk,
)
.await?;
tokio::time::sleep(Duration::from_millis(10000)).await;

let pagoda_firebase_audience_id = "not actually used in integration tests";

Expand Down Expand Up @@ -132,6 +149,16 @@ where
result
}

async fn up_funds_for_account(worker: &Worker<Sandbox>, id: &AccountId) -> anyhow::Result<()> {
const AMOUNT: u128 = 99 * 10u128.pow(24);
for _ in 0..10 {
let tmp_account = worker.dev_create_account().await?;
tmp_account.transfer_near(id, AMOUNT).await?.into_result()?;
tmp_account.delete_account(id).await?.into_result()?;
}
Ok(())
}

mod account {
use rand::{distributions::Alphanumeric, Rng};
use workspaces::{network::Sandbox, AccountId, Worker};
Expand Down

0 comments on commit 3181018

Please sign in to comment.