Skip to content
Snippets Groups Projects

Use cucumber for integration tests

Merged Éloïs requested to merge elois-cucumber-tests into master
Files
2
@@ -14,39 +14,29 @@
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
use crate::common::*;
use super::*;
use sp_keyring::AccountKeyring;
use subxt::PairSigner;
#[tokio::test]
async fn test_balance_transfer() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
// Spawn a node
let (api, client, _process) = spawn_node().await;
let alice = PairSigner::new(AccountKeyring::Alice.pair());
let dave = AccountKeyring::Dave.to_account_id();
let events = create_block_with_extrinsic(
&client,
pub async fn transfer(
api: &Api,
client: &Client,
from: AccountKeyring,
amount: u64,
to: AccountKeyring,
) -> Result<()> {
let from = PairSigner::new(from.pair());
let to = to.to_account_id();
let _events = create_block_with_extrinsic(
client,
api.tx()
.balances()
.transfer(dave.clone().into(), 512)
.create_signed(&alice, ())
.transfer(to.clone().into(), amount)
.create_signed(&from, ())
.await?,
)
.await?;
println!(
"Balance transfer extrinsic written in blockchain, events: {:?}",
events
);
// verify that Bob's free Balance increased
let dave_post = api.storage().system().account(dave, None).await?;
println!("Bob's Free Balance is now {}\n", dave_post.data.free);
assert_eq!(dave_post.data.free, 512);
Ok(())
}
Loading