Read Count
Create the read_count
function that queries the current count from the Essential node using the provided node client.
#![allow(unused)] fn main() { async fn read_count(dbs: &utils::db::Dbs) -> essential_types::Word { let r = utils::node::query_state_head(&dbs.node, &ADDRESS, &counter_key().0) .await .unwrap(); extract_count(r).unwrap() } }
Add this section that reads the counter. In this part, we're reading the initial count from our deployed counter contract and assert that it starts at zero. This verifies that our counter is deployed and hasn't been incremented yet.
#![allow(unused)] fn main() { #[tokio::test] async fn test() { // ... let count = read_count(&dbs).await; assert_eq!(count, 0); } }