What does this error mean? I am testing if msg_asset_id().bits() is the same as AssetId::new(ContractId::this(), sub_id).bits();
This is my code:
contract;
use std::{
constants::ZERO_B256,
hash::sha256,
asset::transfer,
hash::Hash,
asset_id::AssetId,
asset::{
burn,
mint_to,
},
contract_id::ContractId,
call_frames::{
msg_asset_id,
},
context::msg_amount,
string::String,
};
abi MyContract {
#[storage(read, write)]
fn deposit()-> b256;
#[storage(read)]
fn test_deposit_asset_id_same_generated() -> b256;
}
storage {
deposits: StorageMap<(Identity, b256), u64> = StorageMap {},
}
impl MyContract for Contract {
#[storage(read, write)]
fn deposit() -> b256{
let owner = msg_sender().unwrap();
let asset_id = msg_asset_id().bits();
asset_id
}
#[storage(read)]
fn test_deposit_asset_id_same_generated() -> b256 {
let token_id = b256::zero();
let token_address = ZERO_B256;
let sub_id = sha256((token_address, token_id));
let owner = msg_sender().unwrap();
let asset_id: b256 = AssetId::new(ContractId::this(), sub_id).bits();
asset_id
}
}
#[test]
fn test_meaning_of_life() {
let instance = abi(MyContract, CONTRACT_ID);
let result = instance.deposit();
let result2 = instance.test_deposit_asset_id_same_generated();
assert(result == result2);
}
failures:
- test test_meaning_of_life, "/home/testtest/Desktop/test_asset/src/main.sw":62
revert code: ffffffffffff0004 -- Failing call to `std::assert::assert`
Logs: []
Result: FAILED. 0 passed. 1 failed. Finished in 567.146µs.