#What is the approach to test the Stellar Asset Contract?

1 messages · Page 1 of 1 (latest)

jolly dock
#

What is the approach to test Stellar Asset Contract?

#

What is the approach to test the Stellar Asset Contract?

red vapor
jolly dock
#

yeah I was reading that example, but they always use a initialize function for providing the contract admin, and the token metadata, which doesn't exist on the token contract interface, or for testing purposes a stellar asset contract needs to be implemented from scratch to be able to use it on the tests? because I thought I could use the soroban_token_spec.wasm but even when I can successfully instantiate a client, it doesn't have the initialize function available, and IDK if that is causing the contract to fail, because the token contract is not correctly initialized yet.

red vapor
#

init_asset now i think

#

i haven't tried this for a while unfortunately

#

i'm not sure what the bytes are supposed to be, a token id i think?

#

perhaps that example needs updated i can't get it to work getting a host error

#

tests work tho so im probably doing something wrong will let you know if i figure it out. someone else will probably get the answer in the meantime 😆

jolly dock
#

Yes, it is very similar to the behavior I am getting 😄 , I will also keep checking it and come back if I find anything. thank you 🙏

jolly dock
#

Here is a small example of how can this be accomplished using the SDK v0.5.0, if it is useful for anyone, looks like it's easier than the previous approach I used on older version 😁 :


extern crate std;
use soroban_sdk::{symbol, testutils::Address as _, Address, BytesN, Env, IntoVal};

mod token {
    soroban_sdk::contractimport!(file = "./soroban_token_spec.wasm");
}

#[test]
fn test() {
    let e: Env = Default::default();
    let token_admin = Address::random(&e);
    let destination = Address::random(&e);

    let token_client = token::Client::new(&e, &e.register_stellar_asset_contract(token_admin.clone()))

    let dest_balance = token_client.balance(&destination);

    assert_eq!(
        dest_balance,
        0
    );
}
leaden quail
#

yeah, note though that this is still in the middle of the release