Skip to content

Commit d410aab

Browse files
committed
Update tests
1 parent 44c9733 commit d410aab

File tree

1 file changed

+39
-65
lines changed

1 file changed

+39
-65
lines changed

node/tests/integration_tests.rs

+39-65
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,18 @@ async fn it_should_allow_outbidding(rig: &TestRig) -> anyhow::Result<()> {
101101
let alices_balance_updated = rig.spaced.client.wallet_get_balance(ALICE).await?;
102102

103103
assert_eq!(
104-
alices_spaces.len() - 1,
105-
alice_spaces_updated.len(),
104+
alices_spaces.winning.len() - 1,
105+
alice_spaces_updated.winning.len(),
106106
"alice must have one less space"
107107
);
108+
// assert_eq!(
109+
// alices_spaces.outbid.len() + 1,
110+
// alice_spaces_updated.outbid.len(),
111+
// "alice must have one less space"
112+
// );
108113
assert_eq!(
109-
bobs_spaces.len() + 1,
110-
bob_spaces_updated.len(),
114+
bobs_spaces.winning.len() + 1,
115+
bob_spaces_updated.winning.len(),
111116
"bob must have a new space"
112117
);
113118
assert_eq!(
@@ -254,8 +259,8 @@ async fn it_should_only_accept_forced_zero_value_bid_increments_and_revoke(
254259
let eve_spaces_updated = rig.spaced.client.wallet_list_spaces(EVE).await?;
255260

256261
assert_eq!(
257-
bob_spaces.len() - 1,
258-
bob_spaces_updated.len(),
262+
bob_spaces.winning.len() - 1,
263+
bob_spaces_updated.winning.len(),
259264
"bob must have one less space"
260265
);
261266
assert_eq!(
@@ -264,8 +269,8 @@ async fn it_should_only_accept_forced_zero_value_bid_increments_and_revoke(
264269
"alice must be refunded this exact amount"
265270
);
266271
assert_eq!(
267-
eve_spaces_updated.len(),
268-
eve_spaces.len(),
272+
eve_spaces_updated.winning.len(),
273+
eve_spaces.winning.len(),
269274
"eve must have the same number of spaces"
270275
);
271276

@@ -319,7 +324,7 @@ async fn it_should_allow_claim_on_or_after_claim_height(rig: &TestRig) -> anyhow
319324
rig.wait_until_wallet_synced(wallet).await?;
320325
let all_spaces_2 = rig.spaced.client.wallet_list_spaces(wallet).await?;
321326

322-
assert_eq!(all_spaces.len(), all_spaces_2.len(), "must be equal");
327+
assert_eq!(all_spaces.owned.len() + 1, all_spaces_2.owned.len(), "must be equal");
323328

324329
let space = rig
325330
.spaced
@@ -343,14 +348,9 @@ async fn it_should_allow_batch_transfers_refreshing_expire_height(
343348
rig.wait_until_synced().await?;
344349
let all_spaces = rig.spaced.client.wallet_list_spaces(ALICE).await?;
345350
let registered_spaces: Vec<_> = all_spaces
351+
.owned
346352
.iter()
347-
.filter_map(|s| {
348-
let space = s.space.as_ref().expect("space");
349-
match space.covenant {
350-
Covenant::Transfer { .. } => Some(space.name.to_string()),
351-
_ => None,
352-
}
353-
})
353+
.map(|out| out.spaceout.space.as_ref().expect("space").name.to_string())
354354
.collect();
355355

356356
let space_address = rig
@@ -380,14 +380,12 @@ async fn it_should_allow_batch_transfers_refreshing_expire_height(
380380
rig.wait_until_wallet_synced(ALICE).await?;
381381
let all_spaces_2 = rig.spaced.client.wallet_list_spaces(ALICE).await?;
382382

383-
assert_eq!(all_spaces.len(), all_spaces_2.len(), "must be equal");
383+
assert_eq!(all_spaces.owned.len(), all_spaces_2.owned.len(), "must be equal");
384384

385-
let mut count = 0;
386-
all_spaces_2.iter().for_each(|s| {
387-
let space = s.space.as_ref().expect("space");
385+
let _ = all_spaces_2.owned.iter().for_each(|s| {
386+
let space = s.spaceout.space.as_ref().expect("space");
388387
match space.covenant {
389388
Covenant::Transfer { expire_height, .. } => {
390-
count += 1;
391389
assert_eq!(
392390
expire_height, expected_expire_height,
393391
"must refresh expire height"
@@ -396,14 +394,10 @@ async fn it_should_allow_batch_transfers_refreshing_expire_height(
396394
_ => {}
397395
}
398396
});
397+
399398
assert_eq!(
400-
count,
401-
registered_spaces.len(),
402-
"must keep the exact number of registered spaces"
403-
);
404-
assert_eq!(
405-
all_spaces.len(),
406-
all_spaces_2.len(),
399+
all_spaces.winning.len(),
400+
all_spaces_2.winning.len(),
407401
"shouldn't change number of held spaces"
408402
);
409403

@@ -414,16 +408,8 @@ async fn it_should_allow_applying_script_in_batch(rig: &TestRig) -> anyhow::Resu
414408
rig.wait_until_wallet_synced(ALICE).await?;
415409
rig.wait_until_synced().await?;
416410
let all_spaces = rig.spaced.client.wallet_list_spaces(ALICE).await?;
417-
let registered_spaces: Vec<_> = all_spaces
418-
.iter()
419-
.filter_map(|s| {
420-
let space = s.space.as_ref().expect("space");
421-
match space.covenant {
422-
Covenant::Transfer { .. } => Some(space.name.to_string()),
423-
_ => None,
424-
}
425-
})
426-
.collect();
411+
let registered_spaces: Vec<_> = all_spaces.owned.iter().map(|out|
412+
out.spaceout.space.as_ref().expect("space").name.to_string()).collect();
427413

428414
let result = wallet_do(
429415
rig,
@@ -452,17 +438,16 @@ async fn it_should_allow_applying_script_in_batch(rig: &TestRig) -> anyhow::Resu
452438
rig.wait_until_wallet_synced(ALICE).await?;
453439
let all_spaces_2 = rig.spaced.client.wallet_list_spaces(ALICE).await?;
454440

455-
assert_eq!(all_spaces.len(), all_spaces_2.len(), "must be equal");
441+
assert_eq!(all_spaces.owned.len(), all_spaces_2.owned.len(), "must be equal");
442+
assert_eq!(all_spaces.winning.len(), all_spaces_2.winning.len(), "must be equal");
456443

457-
let mut count = 0;
458-
all_spaces_2.iter().for_each(|s| {
459-
let space = s.space.as_ref().expect("space");
444+
all_spaces_2.owned.iter().for_each(|s| {
445+
let space = s.spaceout.space.as_ref().expect("space");
460446
match &space.covenant {
461447
Covenant::Transfer {
462448
expire_height,
463449
data,
464450
} => {
465-
count += 1;
466451
assert_eq!(
467452
*expire_height, expected_expire_height,
468453
"must refresh expire height"
@@ -477,17 +462,6 @@ async fn it_should_allow_applying_script_in_batch(rig: &TestRig) -> anyhow::Resu
477462
_ => {}
478463
}
479464
});
480-
assert_eq!(
481-
count,
482-
registered_spaces.len(),
483-
"must keep the exact number of registered spaces"
484-
);
485-
assert_eq!(
486-
all_spaces.len(),
487-
all_spaces_2.len(),
488-
"shouldn't change number of held spaces"
489-
);
490-
491465
Ok(())
492466
}
493467

@@ -911,25 +885,25 @@ async fn it_can_batch_txs(rig: &TestRig) -> anyhow::Result<()> {
911885
rig.wait_until_wallet_synced(BOB).await.expect("synced");
912886

913887
let bob_spaces = rig.spaced.client.wallet_list_spaces(BOB).await.expect("bob spaces");
914-
assert!(bob_spaces.iter().find(|output|
915-
output.space.as_ref().is_some_and(|s| s.name.to_string() == "@test9996")).is_some(),
888+
assert!(bob_spaces.owned.iter().find(|output|
889+
output.spaceout.space.as_ref().is_some_and(|s| s.name.to_string() == "@test9996")).is_some(),
916890
"expected bob to own the space name"
917891
);
918892

919893
let alice_spaces = rig.spaced.client.wallet_list_spaces(ALICE).await.expect("alice spaces");
920-
let batch1 = alice_spaces.iter().find(|output|
921-
output.space.as_ref().is_some_and(|s| s.name.to_string() == "@batch1"))
922-
.expect("exists").space.clone().expect("space exists");
894+
let batch1 = alice_spaces.winning.iter().find(|output|
895+
output.spaceout.space.as_ref().is_some_and(|s| s.name.to_string() == "@batch1"))
896+
.expect("exists").spaceout.space.clone().expect("space exists");
923897

924898
match batch1.covenant {
925899
Covenant::Bid { total_burned, .. } => {
926900
assert_eq!(total_burned.to_sat(), 1000, "incorrect burn value")
927901
}
928902
_ => panic!("must be a bid")
929903
}
930-
let batch2 = alice_spaces.iter().find(|output|
931-
output.space.as_ref().is_some_and(|s| s.name.to_string() == "@batch2"))
932-
.expect("exists").space.clone().expect("space exists");
904+
let batch2 = alice_spaces.winning.iter().find(|output|
905+
output.spaceout.space.as_ref().is_some_and(|s| s.name.to_string() == "@batch2"))
906+
.expect("exists").spaceout.space.clone().expect("space exists");
933907
match batch2.covenant {
934908
Covenant::Bid { total_burned, .. } => {
935909
assert_eq!(total_burned.to_sat(), 1000, "incorrect burn value")
@@ -942,9 +916,9 @@ async fn it_can_batch_txs(rig: &TestRig) -> anyhow::Result<()> {
942916
"@test9999".to_string(),
943917
"@test9998".to_string()
944918
] {
945-
let space = alice_spaces.iter().find(|output|
946-
output.space.as_ref().is_some_and(|s| s.name.to_string() == space))
947-
.expect("exists").space.clone().expect("space exists");
919+
let space = alice_spaces.owned.iter().find(|output|
920+
output.spaceout.space.as_ref().is_some_and(|s| s.name.to_string() == space))
921+
.expect("exists").spaceout.space.clone().expect("space exists");
948922

949923
match space.covenant {
950924
Covenant::Transfer { data, .. } => {

0 commit comments

Comments
 (0)