Skip to content

Commit

Permalink
add wasm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alrighttt committed Sep 14, 2024
1 parent dad8050 commit 1983161
Showing 1 changed file with 74 additions and 6 deletions.
80 changes: 74 additions & 6 deletions mm2src/coins/siacoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,17 +1240,85 @@ mod wasm_tests {

wasm_bindgen_test_configure!(run_in_browser);

async fn init_client() -> SiaClientType {
let conf = SiaClientConf {
server_url: Url::parse("https://sia-walletd.komodo.earth/").unwrap(),
headers: HashMap::new(),
};
SiaClientType::new(conf).await.unwrap()
}

#[wasm_bindgen_test]
async fn test_sia_anything() {
async fn test_endpoint_txpool_broadcast() {
register_wasm_log();

use sia_rust::transaction::V2Transaction;


let client = init_client().await;

let tx = serde_json::from_str::<V2Transaction>(
r#"
{
"siacoinInputs": [
{
"parent": {
"id": "h:27248ab562cbbee260e07ccae87c74aae71c9358d7f91eee25837e2011ce36d3",
"leafIndex": 21867,
"merkleProof": [
"h:ac2fdcbed40f103e54b0b1a37c20a865f6f1f765950bc6ac358ff3a0e769da50",
"h:b25570eb5c106619d4eef5ad62482023df7a1c7461e9559248cb82659ebab069",
"h:baa78ec23a169d4e9d7f801e5cf25926bf8c29e939e0e94ba065b43941eb0af8",
"h:239857343f2997462bed6c253806cf578d252dbbfd5b662c203e5f75d897886d",
"h:ad727ef2112dc738a72644703177f730c634a0a00e0b405bd240b0da6cdfbc1c",
"h:4cfe0579eabafa25e98d83c3b5d07ae3835ce3ea176072064ea2b3be689e99aa",
"h:736af73aa1338f3bc28d1d8d3cf4f4d0393f15c3b005670f762709b6231951fc"
],
"siacoinOutput": {
"value": "772999980000000000000000000",
"address": "addr:1599ea80d9af168ce823e58448fad305eac2faf260f7f0b56481c5ef18f0961057bf17030fb3"
},
"maturityHeight": 0
},
"satisfiedPolicy": {
"policy": {
"type": "pk",
"policy": "ed25519:968e286ef5df3954b7189c53a0b4b3d827664357ebc85d590299b199af46abad"
},
"signatures": [
"sig:7a2c332fef3958a0486ef5e55b70d2a68514ff46d9307a85c3c0e40b76a19eebf4371ab3dd38a668cefe94dbedff2c50cc67856fbf42dce2194b380e536c1500"
]
}
}
],
"siacoinOutputs": [
{
"value": "2000000000000000000000000",
"address": "addr:1d9a926b1e14b54242375c7899a60de883c8cad0a45a49a7ca2fdb6eb52f0f01dfe678918204"
},
{
"value": "770999970000000000000000000",
"address": "addr:1599ea80d9af168ce823e58448fad305eac2faf260f7f0b56481c5ef18f0961057bf17030fb3"
}
],
"minerFee": "10000000000000000000"
}
"#).unwrap();

let request = TxpoolBroadcastRequest {
transactions: vec![],
v2transactions: vec![tx],
};
let resp = client.dispatcher(request).await.unwrap();
}

#[wasm_bindgen_test]
async fn test_helper_address_balance() {
register_wasm_log();
use sia_rust::http::endpoints::AddressBalanceRequest;
use sia_rust::types::Address;

let conf = SiaClientConf {
server_url: Url::parse("https://sia-walletd.komodo.earth/").unwrap(),
headers: HashMap::new(),
};
let client = SiaClientType::new(conf).await.unwrap();
let client = init_client().await;

client
.address_balance(
Expand Down

0 comments on commit 1983161

Please sign in to comment.