Skip to content

Commit

Permalink
fix nia_with_media test
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedberg committed Dec 15, 2023
1 parent 18474b9 commit ce1fbe9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,6 @@ impl Wallet {
let seal = GraphSeal::from(seal);
let concealed_seal = seal.to_concealed_seal();
let blinded_utxo = concealed_seal.to_string();
debug!(self.logger, "Recipient ID '{}'", blinded_utxo);

let (invoice, expiration_timestamp, asset_transfer_idx) = self._receive(
asset_id,
Expand Down Expand Up @@ -2011,7 +2010,6 @@ impl Wallet {
let address_str = self._get_new_address().to_string();
let address = Address::from_str(&address_str).unwrap().assume_checked();
let script_buf_str = address.script_pubkey().to_hex_string();
debug!(self.logger, "Recipient ID '{}'", script_buf_str);

let (invoice, expiration_timestamp, _) = self._receive(
asset_id,
Expand Down
27 changes: 21 additions & 6 deletions src/wallet/test/refresh.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::*;
use rgbstd::interface::rgb21::EmbeddedMedia as RgbEmbeddedMedia;
use rgbstd::stl::ProofOfReserves as RgbProofOfReserves;
use sea_orm::EntityTrait;
use serial_test::{parallel, serial};

#[test]
Expand Down Expand Up @@ -314,16 +315,30 @@ fn nia_with_media() {
let mime = tree_magic::from_filepath(fpath);
let media_ty: &'static str = Box::leak(mime.clone().into_boxed_str());
let media_type = MediaType::with(media_ty);
let media = Attachment {
let attachment = Attachment {
ty: media_type,
digest,
};
MOCK_CONTRACT_DATA.lock().unwrap().push(media.clone());
MOCK_CONTRACT_DATA.lock().unwrap().push(attachment.clone());
let asset = test_issue_asset_nia(&wallet_1, &online_1, None);
let digest = hex::encode(media.digest);
let media_dir = wallet_1.wallet_dir.join(MEDIA_DIR);
fs::create_dir_all(&media_dir).unwrap();
fs::copy(fp, media_dir.join(digest)).unwrap();
let media_idx = wallet_1
._copy_media_and_save(
fp,
&Media::from_attachment(&attachment, wallet_1._media_dir()),
)
.unwrap();
let db_asset = wallet_1
.database
.get_asset(asset.asset_id.clone())
.unwrap()
.unwrap();
let mut updated_asset: DbAssetActMod = db_asset.into();
updated_asset.media_idx = ActiveValue::Set(Some(media_idx));
block_on(
crate::database::entities::asset::Entity::update(updated_asset)
.exec(wallet_1.database.get_connection()),
)
.unwrap();

let receive_data = test_blind_receive(&wallet_2);
let recipient_map = HashMap::from([(
Expand Down

0 comments on commit ce1fbe9

Please sign in to comment.