Skip to content

Commit

Permalink
Add withdraw nft to pending balance
Browse files Browse the repository at this point in the history
Signed-off-by: deniallugo <[email protected]>
  • Loading branch information
Deniallugo committed May 13, 2022
1 parent 9aea37c commit dca3fa6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
3 changes: 1 addition & 2 deletions core/lib/eth_client/src/clients/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,7 @@ impl<S: EthereumSigner> ETHDirectClient<S> {
.function(func)
.expect("failed to get function parameters");

let tokens = params.into_tokens();
f.encode_input(&tokens)
f.encode_input(&params.into_tokens())
.expect("failed to encode parameters")
}

Expand Down
3 changes: 1 addition & 2 deletions core/tests/testkit/src/bin/gas_price_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct CostsSample {
verify_cost: BigInt,
/// Operator withdrawal gas cost
withdrawals_cost: BigInt,
/// Operator withdrawal gas cost
/// Pending withdrawer withdrawal gas cost
pending_withdrawals_cost: BigInt,
}

Expand Down Expand Up @@ -98,7 +98,6 @@ impl CostsSample {
commit_cost,
verify_cost,
withdraw_cost,
// We withdraw just one
pending_withdraw_cost,
total,
}
Expand Down
15 changes: 8 additions & 7 deletions core/tests/testkit/src/eth_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,10 @@ impl EthereumAccount {
.blocks
.iter()
.flat_map(|b| {
b.block_transactions
.iter()
.filter(|a| a.is_successful() && (a.variance_name() == "Withdraw"))
b.block_transactions.iter().filter(|a| {
a.is_successful()
&& (a.variance_name() == "Withdraw" || a.variance_name() == "WithdrawNFT")
})
})
.collect();
let mut ft_balances = vec![];
Expand All @@ -453,12 +454,12 @@ impl EthereumAccount {
match ex_op {
ZkSyncTx::Withdraw(tx) => ft_balances.push(Token::Tuple(vec![
Token::Address(tx.to),
Token::Address(tokens.get(&tx.token).unwrap().clone()),
Token::Uint(Uint::from(2_000_000)),
Token::Address(*tokens.get(&tx.token).unwrap()),
Token::Uint(Uint::from(200_000)),
])),
ZkSyncTx::WithdrawNFT(tx) => nft_balances.push(Token::Tuple(vec![
Token::Uint(Uint::from_str(&tx.token.0.to_string()).unwrap()),
Token::Uint(Uint::from(3_000_000)),
Token::Uint(Uint::from(300_000)),
])),
_ => unreachable!(),
};
Expand Down Expand Up @@ -550,7 +551,7 @@ impl EthereumAccount {
#[derive(Debug, Clone)]
pub struct ETHExecResult {
success: bool,
pub receipt: TransactionReceipt,
receipt: TransactionReceipt,
revert_reason: String,
}

Expand Down
12 changes: 8 additions & 4 deletions core/tests/testkit/src/external_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ fn get_contract_address(deploy_script_out: &str) -> Option<(String, Address)> {
}
}

fn pending_withdrawer_contract() -> ethabi::Contract {
let path = "contracts/artifacts/cache/solpp-generated-contracts/dev-contracts/PendingBalanceWithdrawer.sol/PendingBalanceWithdrawer.json";
let pending_withdrawer_abi: Value =
serde_json::from_slice(read(path).unwrap().as_slice()).unwrap();
serde_json::from_value(pending_withdrawer_abi.get("abi").unwrap().clone()).unwrap()
}

/// Runs external command and returns stdout output
fn run_external_command(command: &str, args: &[&str]) -> String {
let result = Command::new(command)
Expand Down Expand Up @@ -113,9 +120,6 @@ pub fn deploy_contracts(use_prod_contracts: bool, genesis_root: Fr) -> Contracts
contracts.insert(name, address);
}
}
let pending_withdrawer_abi: Value = serde_json::from_slice( read("contracts/artifacts/cache/solpp-generated-contracts/dev-contracts/PendingBalanceWithdrawer.sol/PendingBalanceWithdrawer.json").unwrap().as_slice()).unwrap();
let contract =
serde_json::from_value(pending_withdrawer_abi.get("abi").unwrap().clone()).unwrap();

Contracts {
governance: contracts
Expand All @@ -134,7 +138,7 @@ pub fn deploy_contracts(use_prod_contracts: bool, genesis_root: Fr) -> Contracts
.remove("CONTRACTS_TEST_ERC20")
.expect("TEST_ERC20 missing"),
pending_withdrawer: (
contract,
pending_withdrawer_contract(),
contracts
.remove("CONTRACTS_PENDING_BALANCE_WITHDRAWER")
.expect("CONTRACTS_PENDING_BALANCE_WITHDRAWER missing"),
Expand Down
2 changes: 0 additions & 2 deletions core/tests/testkit/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate core;

use zksync_types::{Account, AccountId, Address};

pub use self::{
Expand Down
8 changes: 4 additions & 4 deletions infrastructure/zk/src/test/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ export async function testkit(command: string, timeout: number) {
if (command.includes('block_sizes_test ')) {
await utils.spawn(`cargo run --release --bin ${command}`);
} else if (command == 'fast') {
// await utils.spawn('cargo run --bin testkit_tests --release');
await utils.spawn('cargo run --bin testkit_tests --release');
await utils.spawn('cargo run --bin gas_price_test --release');
// await utils.spawn('cargo run --bin revert_blocks_test --release');
// await utils.spawn('cargo run --bin migration_test --release');
// await utils.spawn('cargo run --bin exodus_test --release');
await utils.spawn('cargo run --bin revert_blocks_test --release');
await utils.spawn('cargo run --bin migration_test --release');
await utils.spawn('cargo run --bin exodus_test --release');
} else {
await utils.spawn(`cargo run --bin ${command} --release`);
}
Expand Down

0 comments on commit dca3fa6

Please sign in to comment.