Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph committed Dec 23, 2024
1 parent 74b0500 commit dbd9c23
Showing 1 changed file with 81 additions and 9 deletions.
90 changes: 81 additions & 9 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6367,16 +6367,66 @@ next
.index_runes()
.build();

let rune = Rune(RUNE);

let (txid, id) = server.etch(
Runestone {
edicts: vec![Edict {
id: RuneId::default(),
amount: u128::MAX,
output: 0,
}],
etching: Some(Etching {
divisibility: Some(1),
rune: Some(rune),
premine: Some(u128::MAX),
..default()
}),
..default()
},
1,
None,
);

pretty_assert_eq!(
server.index.runes().unwrap(),
[(
id,
RuneEntry {
block: id.block,
divisibility: 1,
etching: txid,
spaced_rune: SpacedRune { rune, spacers: 0 },
premine: u128::MAX,
timestamp: id.block,
..default()
}
)]
);

server.mine_blocks(1);

let address = "bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202"
.parse::<Address<NetworkUnchecked>>()
.unwrap()
.require_network(Network::Regtest)
.unwrap();

// merge rune with two inscriptions
let txid = server.core.broadcast_tx(TransactionTemplate {
inputs: &[(1, 0, 0, inscription("text/plain", "foo").to_witness())],
inputs: &[
(6, 0, 0, inscription("text/plain", "foo").to_witness()),
(7, 0, 0, inscription("text/plain", "bar").to_witness()),
(7, 1, 0, Witness::new()),
],
recipient: Some(address.clone()),
..default()
});

server.mine_blocks(1);

let inscription_id = InscriptionId { txid, index: 0 };
let second_inscription_id = InscriptionId { txid, index: 1 };
let outpoint: OutPoint = OutPoint { txid, vout: 0 };

let output_recursive =
Expand All @@ -6385,12 +6435,27 @@ next
pretty_assert_eq!(
output_recursive,
api::OutputRecursive {
address: None,
inscriptions: Some(vec![inscription_id]),
runes: Some(BTreeMap::new()),
sat_ranges: Some(vec![(50 * COIN_VALUE, 100 * COIN_VALUE)]),
script_pubkey: ScriptBuf::new(),
value: 50 * COIN_VALUE,
address: Some(address.as_unchecked().clone()),
inscriptions: Some(vec![inscription_id, second_inscription_id]),
runes: Some(
[(
SpacedRune { rune, spacers: 0 },
Pile {
amount: u128::MAX,
divisibility: 1,
symbol: None
}
)]
.into_iter()
.collect()
),
sat_ranges: Some(vec![
(6 * 50 * COIN_VALUE, 7 * 50 * COIN_VALUE),
(7 * 50 * COIN_VALUE, 8 * 50 * COIN_VALUE),
(50 * COIN_VALUE, 2 * 50 * COIN_VALUE)
]),
script_pubkey: address.script_pubkey(),
value: 150 * COIN_VALUE,
}
);
}
Expand All @@ -6401,8 +6466,15 @@ next

server.mine_blocks(1);

let address = "bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202"
.parse::<Address<NetworkUnchecked>>()
.unwrap()
.require_network(Network::Regtest)
.unwrap();

let txid = server.core.broadcast_tx(TransactionTemplate {
inputs: &[(1, 0, 0, inscription("text/plain", "foo").to_witness())],
recipient: Some(address.clone()),
..default()
});

Expand All @@ -6417,11 +6489,11 @@ next
pretty_assert_eq!(
output_recursive,
api::OutputRecursive {
address: None,
address: Some(address.as_unchecked().clone()),
inscriptions: Some(vec![inscription_id]),
runes: None,
sat_ranges: None,
script_pubkey: ScriptBuf::new(),
script_pubkey: address.script_pubkey(),
value: 50 * COIN_VALUE,
}
);
Expand Down

0 comments on commit dbd9c23

Please sign in to comment.