Forráskód Böngészése

Add support for update tokens

Cesar Rodas 9 hónapja
szülő
commit
57e6ff492d
1 módosított fájl, 8 hozzáadás és 4 törlés
  1. 8 4
      utxo/tests/ledger.rs

+ 8 - 4
utxo/tests/ledger.rs

@@ -6,7 +6,7 @@ use std::{
     sync::Arc,
 };
 use tokio::{fs, io};
-use verax::{storage::SQLite, AccountId, Amount, Asset, RevId};
+use verax::{storage::SQLite, AccountId, Amount, Asset, RevId, TokenPayload};
 
 #[derive(Debug, Clone)]
 pub enum Variable {
@@ -31,6 +31,7 @@ pub struct LedgerWorld {
     ledger: Arc<verax::Ledger<SQLite>>,
     variables: HashMap<String, Variable>,
     spend: Option<Vec<(AccountId, Amount)>>,
+    tokens: Vec<TokenPayload>,
     receive: Option<Vec<(AccountId, Amount)>>,
 }
 
@@ -54,6 +55,7 @@ impl Default for LedgerWorld {
             Self {
                 ledger: verax::Ledger::new(db.into()),
                 variables: HashMap::new(),
+                tokens: vec![],
                 spend: None,
                 receive: None,
             }
@@ -105,7 +107,7 @@ async fn commit_transaction_and_expect_to_fail(world: &mut LedgerWorld, status:
 
     assert!(world
         .ledger
-        .new_transaction("Transaction".to_owned(), status, spend, receive)
+        .new_transaction("Transaction".to_owned(), status, spend, receive, None)
         .await
         .is_err());
 }
@@ -121,7 +123,7 @@ async fn commit_transaction(world: &mut LedgerWorld, name: String, status: Strin
         name,
         world
             .ledger
-            .new_transaction("Transaction".to_owned(), status, spend, receive)
+            .new_transaction("Transaction".to_owned(), status, spend, receive, None)
             .await
             .map(|x| x.revision_id)
             .into(),
@@ -149,6 +151,7 @@ async fn deposit_funds(
                 status.parse().expect("valid status"),
                 vec![],
                 "Initial deposit".to_owned(),
+                None,
             )
             .await
             .map(|x| x.revision_id)
@@ -164,12 +167,13 @@ async fn update_status_from_last_tx(world: &mut LedgerWorld, tx: String, new_sta
         _ => panic!("{} is not a RevId", tx),
     };
     let status = new_status.parse().expect("valid status");
+    let update_token = world.tokens.pop();
 
     world.variables.insert(
         tx,
         world
             .ledger
-            .change_status(revision, status, "update status".to_owned())
+            .change_status(revision, status, "update status".to_owned(), update_token)
             .await
             .map(|x| x.revision_id)
             .into(),