|
| 1 | +use std::fs; |
| 2 | +use std::path::Path; |
| 3 | + |
| 4 | +use rpc_client::ckb_client::ckb_rpc_client::CkbRpcClient; |
| 5 | +use tx_builder::ckb::helper::OmniEth; |
| 6 | + |
| 7 | +use crate::config::types::PrivKeys; |
| 8 | +use crate::tx::*; |
| 9 | +use crate::ROCKSDB_PATH; |
| 10 | + |
| 11 | +// There is only one staker or delegator. |
| 12 | +pub async fn run_case1(ckb: &CkbRpcClient, priv_keys: PrivKeys) { |
| 13 | + if Path::new(ROCKSDB_PATH).exists() { |
| 14 | + fs::remove_dir_all(ROCKSDB_PATH).unwrap(); |
| 15 | + } |
| 16 | + |
| 17 | + let kicker_key = priv_keys.staker_privkeys[0].clone().into_h256().unwrap(); |
| 18 | + let staker_key = priv_keys.staker_privkeys[0].clone().into_h256().unwrap(); |
| 19 | + let delegator_key = priv_keys.delegator_privkeys[0].clone().into_h256().unwrap(); |
| 20 | + let staker_eth_addr = OmniEth::new(staker_key.clone()).address().unwrap(); |
| 21 | + |
| 22 | + run_init_tx(ckb, priv_keys.clone()).await; |
| 23 | + run_mint_tx(ckb, priv_keys.clone()).await; |
| 24 | + |
| 25 | + first_stake_tx(ckb, staker_key.clone()).await; |
| 26 | + add_stake_tx(ckb, staker_key.clone()).await; |
| 27 | + run_stake_smt_tx(ckb, kicker_key.clone()).await; |
| 28 | + |
| 29 | + reedem_stake_tx(ckb, staker_key.clone()).await; |
| 30 | + run_stake_smt_tx(ckb, kicker_key.clone()).await; |
| 31 | + |
| 32 | + first_delegate_tx(ckb, delegator_key.clone(), staker_eth_addr.clone()).await; |
| 33 | + add_delegate_tx(ckb, delegator_key.clone(), staker_eth_addr.clone()).await; |
| 34 | + run_delegate_smt_tx(ckb, kicker_key.clone()).await; |
| 35 | + |
| 36 | + reedem_delegate_tx(ckb, delegator_key, staker_eth_addr).await; |
| 37 | + run_delegate_smt_tx(ckb, kicker_key.clone()).await; |
| 38 | + |
| 39 | + run_metadata_tx(ckb, kicker_key.clone()).await; |
| 40 | + |
| 41 | + run_checkpoint_tx(ckb, priv_keys.clone(), 1).await; |
| 42 | + run_checkpoint_tx(ckb, priv_keys.clone(), 2).await; |
| 43 | + |
| 44 | + run_reward_tx(ckb, staker_key.clone()).await; |
| 45 | + |
| 46 | + run_withdraw_tx(ckb, staker_key.clone()).await; |
| 47 | +} |
0 commit comments