Compete

In this final section test how the counter handles competing increments. We increment the counter twice with two solutions setting the count to the same value. Then verify that only one increment succeeds when we build the block. This demonstrates that when two solutions compete for the same state only one will win.

#![allow(unused)]
fn main() {
#[tokio::test]
async fn test() {
    // ...

    increment(&dbs).await;
    increment(&dbs).await;

    let o = utils::builder::build_default(&dbs).await.unwrap();
    assert_eq!(o.succeeded.len(), 2);

    let count = read_count(&dbs).await;
    assert_eq!(count, 2);
}
}

Currently the builder uses a simple FIFO approach to choosing which solutions wins but this will change to more advanced strategies in the future.