sway icon indicating copy to clipboard operation
sway copied to clipboard

Simple unit test is failing to execute `csiz`

Open kayagokalp opened this issue 1 year ago • 2 comments

Following test is failing on line 3, where the asm block is executed.

#[test]
fn do_test() {
    let child_contract = simple_contract::CONTRACT_ID;
    let registry = registry_contract::CONTRACT_ID;
    let mut length = asm(
        load_target: child_contract,  
        length,
    
    ) {
        csiz length load_target;
        length
    };
    // length of the fake child contract
    log(length);
}

Following simple contract is added as a contract dependency to the first project.

contract;

configurable {
    VALUE: u64 = 1,
}

abi MyContract {
    fn test_function() -> u64;
}

impl MyContract for Contract {
    // All this contract does is return the stored configurable value
    fn test_function() -> u64 {
        VALUE
    }
}

kayagokalp avatar Jul 31 '24 10:07 kayagokalp

This needs some investigation on our end, as it might not be the case that the reason for failure is due to the csiz

kayagokalp avatar Jul 31 '24 10:07 kayagokalp

I'm not able to repro this. I think I followed your steps correctly, but the test is passing. Could you check if this still repros on master? If so, a gist or a branch with the projects would be helpful.

sdankel avatar Sep 10 '24 01:09 sdankel