Skip to content

Conversation

PatrickDinh
Copy link
Collaborator

Fixes #

Proposed Changes

use crate::{Address, AssetFreezeTransactionBuilder, Byte32, TransactionHeaderBuilder};
use base64::{prelude::BASE64_STANDARD, Engine};

pub struct AssetFreezeTransactionMother {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test data builder for asset freeze are refactored to another file, similar to https://github.com/algorandfoundation/algokit-core/blob/main/crates/algokit_transact/src/test_utils/asset_config.rs

}

pub fn asset_unfreeze() -> AssetFreezeTransactionBuilder {
// testnet-LZ2ODDAT4ATAVJUEQW34DIKMPCMBXCCHOSIYKMWGBPEVNHLSEV2A
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An asset unfreeze transaction is built with real data from testnet. This allows us to confirm that our encoding is correct.

}

#[test]
fn test_asset_unfreeze_snapshot() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test snapshot to make sure that the encoding logic is correct.

}

#[test]
fn test_asset_freeze_transaction_encoding() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this test because the encoding logic is ready verified by the snapshot test. For decoding, I am not sure if we need tests for each transaction type because most of the heavy lifting is done by serde.

}

#[test]
fn test_asset_unfreeze_transaction_encoding() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, encoding is tested by real transaction data in the snapshot test.

}

#[test]
fn test_asset_freeze_real_transaction_ids() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already tested by the snapshot test

}

#[test]
fn test_asset_freeze_required_fields() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this isn't needed, it's testing the builder which is a 3rd party library. I'd trust that they have their own test suite & we don't need to test their logic.

}

#[test]
fn test_asset_freeze_serialization_fields() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like this is testing serde

#[serde(skip_serializing_if = "std::ops::Not::not")]
#[builder(default)]
pub frozen: Option<bool>,
pub frozen: bool,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed your comment earlier this week. The reason is was done this way is the frozen field is a required field for asset freeze transaction. However, only for encoding purposed, it's skipped if the value is False.

!(v.is_null()
|| v.is_boolean()
&& v.as_bool() == Some(false)
&& !BOOLEAN_FIELDS_TO_KEEP.contains(&k.to_case(Case::Snake).as_str())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed, the defaultReviver in TypeScript and Python should set it to false if undefined.

@PatrickDinh PatrickDinh marked this pull request as ready for review July 10, 2025 09:58
@PatrickDinh PatrickDinh requested a review from lempira July 10, 2025 11:13
@lempira lempira merged commit e441e12 into feat/add-asset-freeze-txn Jul 11, 2025
@lempira lempira deleted the pr-feedback branch July 11, 2025 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants