@layerzerolabs/protocol-stellar-v2 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +384 -278
- package/.turbo/turbo-lint.log +110 -78
- package/.turbo/turbo-test.log +1248 -1014
- package/Cargo.lock +130 -3
- package/Cargo.toml +2 -1
- package/contracts/common-macros/src/contract_impl.rs +6 -1
- package/contracts/common-macros/src/lib.rs +47 -8
- package/contracts/common-macros/src/ownable.rs +7 -25
- package/contracts/common-macros/src/storage.rs +1 -1
- package/contracts/common-macros/src/tests/contract_impl.rs +5 -0
- package/contracts/common-macros/src/tests/mod.rs +1 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap +23 -7
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +5 -25
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +48 -48
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +5 -25
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +21 -0
- package/contracts/common-macros/src/tests/upgradeable.rs +31 -0
- package/contracts/common-macros/src/ttl_configurable.rs +14 -44
- package/contracts/common-macros/src/upgradeable.rs +76 -0
- package/contracts/endpoint-v2/src/endpoint_v2.rs +25 -1
- package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +175 -8
- package/contracts/endpoint-v2/src/tests/endpoint_v2/build_outbound_packet.rs +76 -0
- package/contracts/endpoint-v2/src/tests/endpoint_v2/clear.rs +342 -159
- package/contracts/endpoint-v2/src/tests/endpoint_v2/delegate.rs +3 -15
- package/contracts/endpoint-v2/src/tests/endpoint_v2/initializable.rs +20 -31
- package/contracts/endpoint-v2/src/tests/endpoint_v2/lz_receive_alert.rs +126 -164
- package/contracts/endpoint-v2/src/tests/endpoint_v2/mod.rs +1 -0
- package/contracts/endpoint-v2/src/tests/endpoint_v2/native_token.rs +0 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/owner.rs +0 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +311 -304
- package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +423 -96
- package/contracts/endpoint-v2/src/tests/endpoint_v2/recover_token.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +47 -20
- package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +373 -403
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_delegate.rs +96 -22
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +61 -9
- package/contracts/endpoint-v2/src/tests/endpoint_v2/transfer_ownership.rs +4 -4
- package/contracts/endpoint-v2/src/tests/endpoint_v2/ttl_config.rs +8 -11
- package/contracts/endpoint-v2/src/tests/endpoint_v2/verifiable.rs +81 -30
- package/contracts/endpoint-v2/src/tests/endpoint_v2/verify.rs +209 -76
- package/contracts/endpoint-v2/src/tests/endpoint_v2/zro.rs +0 -1
- package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library.rs +24 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library_timeout.rs +40 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/default_send_library.rs +24 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_config.rs +108 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_library_index.rs +52 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_receive_library.rs +92 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_registered_libraries.rs +74 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_send_library.rs +83 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/is_registered_library.rs +32 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/is_supported_eid.rs +28 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/is_valid_receive_library.rs +261 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/mod.rs +16 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/receive_library_timeout.rs +62 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +65 -43
- package/contracts/endpoint-v2/src/tests/message_lib_manager/registered_libraries_count.rs +42 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +61 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +3 -5
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +59 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +15 -1
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_config.rs +155 -51
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_lib_timeout.rs +114 -92
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_library.rs +235 -132
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_send_library.rs +93 -87
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library.rs +346 -245
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library_timeout.rs +406 -60
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_send_library.rs +252 -78
- package/contracts/endpoint-v2/src/tests/message_lib_manager/timeout.rs +102 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/burn.rs +212 -273
- package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +203 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +94 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_nonce.rs +78 -248
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_payload_hash.rs +7 -282
- package/contracts/endpoint-v2/src/tests/messaging_channel/lazy_inbound_nonce.rs +6 -274
- package/contracts/endpoint-v2/src/tests/messaging_channel/mod.rs +3 -2
- package/contracts/endpoint-v2/src/tests/messaging_channel/next_guid.rs +86 -178
- package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +328 -212
- package/contracts/endpoint-v2/src/tests/messaging_channel/outbound.rs +68 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/outbound_nonce.rs +6 -209
- package/contracts/endpoint-v2/src/tests/messaging_channel/skip.rs +207 -159
- package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +142 -153
- package/contracts/endpoint-v2/src/tests/messaging_composer/compose_queue.rs +6 -179
- package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +163 -221
- package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +90 -121
- package/contracts/endpoint-v2/src/tests/mock.rs +18 -4
- package/contracts/endpoint-v2/src/tests/util/build_payload.rs +4 -70
- package/contracts/endpoint-v2/src/tests/util/compute_guid.rs +2 -1
- package/contracts/endpoint-v2/src/tests/util/keccak256.rs +17 -106
- package/contracts/layerzero-views/Cargo.toml +35 -0
- package/contracts/layerzero-views/src/errors.rs +10 -0
- package/contracts/layerzero-views/src/layerzero_view.rs +229 -0
- package/contracts/layerzero-views/src/lib.rs +38 -0
- package/contracts/layerzero-views/src/storage.rs +18 -0
- package/contracts/layerzero-views/src/tests/layerzero_view_tests.rs +423 -0
- package/contracts/layerzero-views/src/tests/mod.rs +4 -0
- package/contracts/layerzero-views/src/tests/setup.rs +377 -0
- package/contracts/layerzero-views/src/types.rs +50 -0
- package/contracts/macro-integration-tests/Cargo.toml +30 -0
- package/contracts/macro-integration-tests/src/lib.rs +1 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/initialization.rs +62 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +22 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/only_owner_guard.rs +97 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/ownership_transfer.rs +101 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/keyed_roundtrip.rs +225 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/mod.rs +4 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/name_override_runtime.rs +52 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/ttl_extension.rs +261 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/unkeyed_roundtrip.rs +137 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +113 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/extend_instance_ttl.rs +50 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +139 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +3 -0
- package/contracts/macro-integration-tests/tests/runtime.rs +5 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.rs +21 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/attr_on_variant_allowed.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/basic_auto_discriminants.rs +15 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/mixed_discriminants.rs +16 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_owner_missing_env.rs +22 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_owner_missing_env.stderr +16 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/minimal_contract.rs +26 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +22 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_owner_env_param_variants.rs +46 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/default_value_on_variant.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_instance_unit_basic.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_persistent_named_fields_keyed.rs +16 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_temporary_unit_option.rs +15 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/name_override.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/no_auto_ttl_extension.rs +19 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/ttl_provider_basic.rs +15 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +44 -0
- package/contracts/macro-integration-tests/tests/ui_error.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_ownable.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_storage.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_ttl_configurable.rs +12 -0
- package/contracts/message-libs/blocked-message-lib/src/lib.rs +17 -17
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +64 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet.rs +58 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet_header.rs +138 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/mod.rs +6 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload.rs +30 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload_hash.rs +15 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/test_helper.rs +39 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_dvn_option.rs +57 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +50 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +74 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +280 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +126 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +48 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/mod.rs +7 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +139 -0
- package/contracts/message-libs/message-lib-common/src/worker_options.rs +31 -1
- package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +2 -2
- package/contracts/message-libs/treasury/src/errors.rs +0 -1
- package/contracts/message-libs/treasury/src/lib.rs +3 -3
- package/contracts/message-libs/treasury/src/storage.rs +2 -0
- package/contracts/message-libs/treasury/src/treasury.rs +12 -13
- package/contracts/message-libs/uln-302/Cargo.toml +1 -1
- package/contracts/message-libs/uln-302/src/errors.rs +0 -5
- package/contracts/message-libs/uln-302/src/events.rs +5 -6
- package/contracts/message-libs/uln-302/src/receive_uln.rs +24 -54
- package/contracts/message-libs/uln-302/src/send_uln.rs +89 -135
- package/contracts/message-libs/uln-302/src/storage.rs +5 -5
- package/contracts/message-libs/uln-302/src/tests/receive_uln302/effective_receive_uln_config.rs +5 -7
- package/contracts/message-libs/uln-302/src/tests/receive_uln302/set_default_receive_uln_configs.rs +3 -3
- package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_send_uln_config.rs +6 -9
- package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_executor_configs.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_send_uln_configs.rs +3 -3
- package/contracts/message-libs/uln-302/src/tests/setup.rs +9 -0
- package/contracts/message-libs/uln-302/src/tests/testing_utils.rs +5 -0
- package/contracts/message-libs/uln-302/src/tests/uln302/get_app_receive_uln_config.rs +1 -2
- package/contracts/message-libs/uln-302/src/tests/uln302/get_app_send_uln_config.rs +1 -2
- package/contracts/message-libs/uln-302/src/tests/uln302/set_config.rs +37 -55
- package/contracts/message-libs/uln-302/src/uln302.rs +8 -5
- package/contracts/oapps/counter/src/counter.rs +0 -1
- package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +306 -224
- package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +0 -1
- package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +0 -1
- package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +0 -1
- package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +0 -1
- package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_core.rs +1 -0
- package/contracts/oapps/oft/integration-tests/setup.rs +10 -3
- package/contracts/oapps/oft/integration-tests/utils.rs +1 -1
- package/contracts/oapps/oft/src/default_oft_impl.rs +9 -3
- package/contracts/oapps/oft/src/extensions/oft_fee.rs +5 -5
- package/contracts/oapps/oft/src/extensions/pausable.rs +1 -1
- package/contracts/oapps/oft/src/extensions/rate_limiter.rs +18 -18
- package/contracts/oapps/oft/src/oft.rs +9 -9
- package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +1 -1
- package/contracts/oapps/oft/src/tests/extensions/setup.rs +26 -11
- package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +1 -1
- package/contracts/oapps/oft/src/tests/test_send.rs +4 -4
- package/contracts/oapps/oft/src/tests/test_utils.rs +93 -74
- package/contracts/oapps/oft-std/Cargo.toml +6 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/mod.rs +3 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/test_oft_fee.rs +157 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/test_pausable.rs +162 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/test_rate_limiter.rs +186 -0
- package/contracts/oapps/oft-std/integration-tests/mod.rs +3 -0
- package/contracts/oapps/oft-std/integration-tests/setup.rs +245 -0
- package/contracts/oapps/oft-std/integration-tests/utils.rs +427 -0
- package/contracts/oapps/oft-std/src/lib.rs +12 -1
- package/contracts/oapps/oft-std/src/oft.rs +122 -25
- package/contracts/upgrader/Cargo.toml +19 -0
- package/contracts/upgrader/src/lib.rs +96 -0
- package/contracts/upgrader/src/tests/mod.rs +1 -0
- package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract1.wasm +0 -0
- package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract2.wasm +0 -0
- package/contracts/upgrader/src/tests/test_upgrader.rs +120 -0
- package/contracts/utils/src/errors.rs +6 -1
- package/contracts/utils/src/lib.rs +2 -1
- package/contracts/utils/src/ownable.rs +49 -61
- package/contracts/utils/src/tests/mod.rs +3 -1
- package/contracts/utils/src/tests/option_ext.rs +21 -0
- package/contracts/utils/src/tests/ownable.rs +10 -69
- package/contracts/utils/src/tests/ttl_configurable.rs +596 -0
- package/contracts/utils/src/tests/upgradeable.rs +288 -0
- package/contracts/utils/src/{ttl.rs → ttl_configurable.rs} +67 -52
- package/contracts/utils/src/upgradeable.rs +54 -0
- package/contracts/workers/dvn/Cargo.toml +1 -1
- package/contracts/workers/dvn/src/auth.rs +21 -32
- package/contracts/workers/dvn/src/dvn.rs +40 -3
- package/contracts/workers/dvn/src/errors.rs +1 -0
- package/contracts/workers/dvn/src/multisig.rs +10 -6
- package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +2 -2
- package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +4 -4
- package/contracts/workers/dvn-fee-lib/Cargo.toml +1 -2
- package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +46 -14
- package/contracts/workers/dvn-fee-lib/src/errors.rs +3 -2
- package/contracts/workers/dvn-fee-lib/src/lib.rs +5 -11
- package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +30 -16
- package/contracts/workers/executor/src/executor.rs +16 -2
- package/contracts/workers/executor-fee-lib/src/errors.rs +9 -7
- package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +154 -119
- package/contracts/workers/executor-helper/Cargo.toml +0 -5
- package/contracts/workers/executor-helper/src/lib.rs +1 -7
- package/contracts/workers/price-feed/Cargo.toml +0 -1
- package/contracts/workers/price-feed/src/errors.rs +3 -2
- package/contracts/workers/price-feed/src/lib.rs +5 -6
- package/contracts/workers/price-feed/src/price_feed.rs +39 -17
- package/contracts/workers/worker/Cargo.toml +4 -0
- package/contracts/workers/worker/src/interfaces/price_feed.rs +3 -3
- package/contracts/workers/worker/src/lib.rs +2 -2
- package/contracts/workers/worker/src/tests/mod.rs +4 -0
- package/contracts/workers/worker/src/tests/setup.rs +147 -0
- package/contracts/workers/worker/src/tests/worker.rs +501 -0
- package/contracts/workers/worker/src/worker.rs +10 -16
- package/package.json +3 -3
- package/sdk/dist/generated/bml.d.ts +40 -30
- package/sdk/dist/generated/bml.js +16 -11
- package/sdk/dist/generated/counter.d.ts +168 -134
- package/sdk/dist/generated/counter.js +26 -21
- package/sdk/dist/generated/dvn.d.ts +1932 -0
- package/sdk/dist/generated/dvn.js +288 -0
- package/sdk/dist/generated/dvn_fee_lib.d.ts +615 -0
- package/sdk/dist/generated/dvn_fee_lib.js +123 -0
- package/sdk/dist/generated/endpoint.d.ts +75 -41
- package/sdk/dist/generated/endpoint.js +22 -17
- package/sdk/dist/generated/executor.d.ts +1809 -0
- package/sdk/dist/generated/executor.js +269 -0
- package/sdk/dist/generated/executor_fee_lib.d.ts +999 -0
- package/sdk/dist/generated/executor_fee_lib.js +208 -0
- package/sdk/dist/generated/executor_helper.d.ts +869 -0
- package/sdk/dist/generated/executor_helper.js +187 -0
- package/sdk/dist/generated/oft_std.d.ts +1544 -0
- package/sdk/dist/generated/oft_std.js +271 -0
- package/sdk/dist/generated/price_feed.d.ts +1002 -0
- package/sdk/dist/generated/price_feed.js +170 -0
- package/sdk/dist/generated/sml.d.ts +75 -41
- package/sdk/dist/generated/sml.js +22 -17
- package/sdk/dist/generated/uln302.d.ts +79 -60
- package/sdk/dist/generated/uln302.js +37 -37
- package/sdk/dist/generated/upgrader.d.ts +70 -0
- package/sdk/dist/generated/upgrader.js +19 -0
- package/sdk/dist/index.d.ts +8 -0
- package/sdk/dist/index.js +11 -0
- package/sdk/package.json +4 -3
- package/sdk/src/index.ts +13 -0
- package/sdk/test/index.test.ts +0 -1
- package/sdk/test/oft.test.ts +12 -23
- package/sdk/test/suites/testUpgradeable.ts +169 -0
- package/sdk/test/upgrader.test.ts +309 -0
- package/tools/ts-bindings-gen/src/main.rs +11 -1
- package/contracts/endpoint-v2/src/tests/messaging_channel/clear.rs +0 -316
- package/contracts/endpoint-v2/src/tests/messaging_channel/internal.rs +0 -388
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1.rs +0 -162
- package/contracts/message-libs/message-lib-common/src/tests/worker_options.rs +0 -319
- package/contracts/utils/src/tests/ttl.rs +0 -421
- /package/contracts/{oapp-macros → oapps/oapp-macros}/Cargo.toml +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/lib.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_full.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_options_type3.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_receiver.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/oapp_sender.rs +0 -0
- /package/contracts/{oapp-macros → oapps/oapp-macros}/src/util.rs +0 -0
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
extern crate std;
|
|
2
|
+
|
|
3
|
+
use crate::errors::TtlConfigurableError;
|
|
4
|
+
use crate::ownable::OwnableInitializer;
|
|
5
|
+
use crate::testing_utils::assert_event;
|
|
6
|
+
use crate::ttl_configurable::{
|
|
7
|
+
TtlConfig, TtlConfigStorage, TtlConfigsFrozen, TtlConfigsSet, TtlConfigurable, LEDGERS_PER_DAY, MAX_TTL,
|
|
8
|
+
};
|
|
9
|
+
use soroban_sdk::{
|
|
10
|
+
contract, contractimpl,
|
|
11
|
+
testutils::{Address as _, MockAuth, MockAuthInvoke},
|
|
12
|
+
Address, Env, IntoVal,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const DEFAULT_INSTANCE_TTL: TtlConfig = TtlConfig::new(5 * LEDGERS_PER_DAY, 10 * LEDGERS_PER_DAY);
|
|
16
|
+
const DEFAULT_PERSISTENT_TTL: TtlConfig = TtlConfig::new(5 * LEDGERS_PER_DAY, 10 * LEDGERS_PER_DAY);
|
|
17
|
+
|
|
18
|
+
// ============================================
|
|
19
|
+
// Test Contract for TTL functionality
|
|
20
|
+
// ============================================
|
|
21
|
+
|
|
22
|
+
#[contract]
|
|
23
|
+
pub struct TtlTestContract;
|
|
24
|
+
|
|
25
|
+
#[contractimpl]
|
|
26
|
+
impl TtlTestContract {
|
|
27
|
+
/// Test-only initializer to set the contract owner (required by `TtlConfigurable`).
|
|
28
|
+
///
|
|
29
|
+
/// NOTE: This is intentionally *not* protected by auth, since it's only used in unit tests.
|
|
30
|
+
pub fn init_owner(env: &Env, owner: Address) {
|
|
31
|
+
<Self as OwnableInitializer>::init_owner(env, &owner);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// TtlConfigStorage storage tests
|
|
35
|
+
pub fn frozen(env: &Env) -> bool {
|
|
36
|
+
TtlConfigStorage::frozen(env)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
pub fn set_frozen(env: &Env, value: bool) {
|
|
40
|
+
TtlConfigStorage::set_frozen(env, &value);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
pub fn instance_ttl(env: &Env) -> TtlConfig {
|
|
44
|
+
TtlConfigStorage::instance(env).unwrap_or(DEFAULT_INSTANCE_TTL)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
pub fn set_instance_ttl(env: &Env, config: TtlConfig) {
|
|
48
|
+
TtlConfigStorage::set_instance(env, &config);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
pub fn has_instance_ttl(env: &Env) -> bool {
|
|
52
|
+
TtlConfigStorage::has_instance(env)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
pub fn remove_instance_ttl(env: &Env) {
|
|
56
|
+
TtlConfigStorage::remove_instance(env);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
pub fn remove_persistent_ttl(env: &Env) {
|
|
60
|
+
TtlConfigStorage::remove_persistent(env);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
pub fn persistent_ttl(env: &Env) -> TtlConfig {
|
|
64
|
+
TtlConfigStorage::persistent(env).unwrap_or(DEFAULT_PERSISTENT_TTL)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
pub fn set_persistent_ttl(env: &Env, config: TtlConfig) {
|
|
68
|
+
TtlConfigStorage::set_persistent(env, &config);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
pub fn has_persistent_ttl(env: &Env) -> bool {
|
|
72
|
+
TtlConfigStorage::has_persistent(env)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// TtlConfigurable tests (via default trait implementation on this contract)
|
|
76
|
+
pub fn configurable_set_ttl_configs(env: &Env, instance: Option<TtlConfig>, persistent: Option<TtlConfig>) {
|
|
77
|
+
<Self as TtlConfigurable>::set_ttl_configs(env, &instance, &persistent);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
pub fn configurable_ttl_configs(env: &Env) -> (Option<TtlConfig>, Option<TtlConfig>) {
|
|
81
|
+
<Self as TtlConfigurable>::ttl_configs(env)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
pub fn configurable_freeze_ttl_configs(env: &Env) {
|
|
85
|
+
<Self as TtlConfigurable>::freeze_ttl_configs(env);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
pub fn is_ttl_configs_frozen(env: &Env) -> bool {
|
|
89
|
+
<Self as TtlConfigurable>::is_ttl_configs_frozen(env)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Enable the default `TtlConfigurable` implementation (which requires `Ownable`) on the test contract.
|
|
94
|
+
//
|
|
95
|
+
// Note: use plain Rust `impl` (not `#[contractimpl(contracttrait)]`) to avoid generating
|
|
96
|
+
// duplicate Soroban contract entrypoints that would collide with this test contract’s helpers.
|
|
97
|
+
impl crate::ownable::Ownable for TtlTestContract {}
|
|
98
|
+
impl OwnableInitializer for TtlTestContract {}
|
|
99
|
+
impl TtlConfigurable for TtlTestContract {}
|
|
100
|
+
|
|
101
|
+
fn setup_contract() -> (Env, Address, Address, TtlTestContractClient<'static>) {
|
|
102
|
+
let env = Env::default();
|
|
103
|
+
let contract_id = env.register(TtlTestContract, ());
|
|
104
|
+
let client = TtlTestContractClient::new(&env, &contract_id);
|
|
105
|
+
let owner = Address::generate(&env);
|
|
106
|
+
client.init_owner(&owner);
|
|
107
|
+
(env, contract_id, owner, client)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fn mock_auth<A: IntoVal<Env, soroban_sdk::Vec<soroban_sdk::Val>>>(
|
|
111
|
+
env: &Env,
|
|
112
|
+
contract_id: &Address,
|
|
113
|
+
address: &Address,
|
|
114
|
+
fn_name: &'static str,
|
|
115
|
+
args: A,
|
|
116
|
+
) {
|
|
117
|
+
env.mock_auths(&[MockAuth {
|
|
118
|
+
address,
|
|
119
|
+
invoke: &MockAuthInvoke { contract: contract_id, args: args.into_val(env), fn_name, sub_invokes: &[] },
|
|
120
|
+
}]);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
fn owner_set_ttl_configs(
|
|
124
|
+
env: &Env,
|
|
125
|
+
contract_id: &Address,
|
|
126
|
+
owner: &Address,
|
|
127
|
+
client: &TtlTestContractClient,
|
|
128
|
+
instance: &Option<TtlConfig>,
|
|
129
|
+
persistent: &Option<TtlConfig>,
|
|
130
|
+
) {
|
|
131
|
+
mock_auth(env, contract_id, owner, "configurable_set_ttl_configs", (instance, persistent));
|
|
132
|
+
client.configurable_set_ttl_configs(instance, persistent);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
fn owner_freeze_ttl_configs(env: &Env, contract_id: &Address, owner: &Address, client: &TtlTestContractClient) {
|
|
136
|
+
mock_auth(env, contract_id, owner, "configurable_freeze_ttl_configs", ());
|
|
137
|
+
client.configurable_freeze_ttl_configs();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ============================================
|
|
141
|
+
// TtlConfig Struct Tests
|
|
142
|
+
// ============================================
|
|
143
|
+
|
|
144
|
+
#[test]
|
|
145
|
+
fn test_ttl_config_new() {
|
|
146
|
+
let config = TtlConfig::new(100, 200);
|
|
147
|
+
assert_eq!(config.threshold, 100);
|
|
148
|
+
assert_eq!(config.extend_to, 200);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#[test]
|
|
152
|
+
fn test_ttl_config_is_valid() {
|
|
153
|
+
// Representative valid configs
|
|
154
|
+
assert!(TtlConfig::new(100, 200).is_valid(300)); // threshold < extend_to < max
|
|
155
|
+
assert!(TtlConfig::new(100, 100).is_valid(200)); // threshold == extend_to
|
|
156
|
+
assert!(TtlConfig::new(0, 0).is_valid(0)); // zeroes allowed
|
|
157
|
+
assert!(TtlConfig::new(MAX_TTL, MAX_TTL).is_valid(MAX_TTL)); // max boundary
|
|
158
|
+
|
|
159
|
+
// Representative invalid configs (the two failure modes)
|
|
160
|
+
assert!(!TtlConfig::new(200, 100).is_valid(300)); // threshold > extend_to
|
|
161
|
+
assert!(!TtlConfig::new(100, 400).is_valid(300)); // extend_to > max
|
|
162
|
+
}
|
|
163
|
+
// ============================================
|
|
164
|
+
// TtlConfigStorage Storage Tests
|
|
165
|
+
// ============================================
|
|
166
|
+
|
|
167
|
+
#[test]
|
|
168
|
+
fn test_ttl_config_data_defaults() {
|
|
169
|
+
let (_, _, _owner, client) = setup_contract();
|
|
170
|
+
|
|
171
|
+
// Default frozen state should be false
|
|
172
|
+
assert!(!client.frozen());
|
|
173
|
+
|
|
174
|
+
// Default TTLs should be returned when not set
|
|
175
|
+
assert_eq!(client.instance_ttl(), DEFAULT_INSTANCE_TTL);
|
|
176
|
+
assert_eq!(client.persistent_ttl(), DEFAULT_PERSISTENT_TTL);
|
|
177
|
+
|
|
178
|
+
// has_* should return false initially
|
|
179
|
+
assert!(!client.has_instance_ttl());
|
|
180
|
+
assert!(!client.has_persistent_ttl());
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
#[test]
|
|
184
|
+
fn test_ttl_config_data_set_get_remove() {
|
|
185
|
+
let (_, _, _owner, client) = setup_contract();
|
|
186
|
+
|
|
187
|
+
let instance_cfg = TtlConfig::new(1000, 2000);
|
|
188
|
+
let persistent_cfg = TtlConfig::new(3000, 4000);
|
|
189
|
+
|
|
190
|
+
// Set and verify instance
|
|
191
|
+
client.set_instance_ttl(&instance_cfg);
|
|
192
|
+
assert!(client.has_instance_ttl());
|
|
193
|
+
assert_eq!(client.instance_ttl(), instance_cfg);
|
|
194
|
+
|
|
195
|
+
// Set and verify persistent
|
|
196
|
+
client.set_persistent_ttl(&persistent_cfg);
|
|
197
|
+
assert!(client.has_persistent_ttl());
|
|
198
|
+
assert_eq!(client.persistent_ttl(), persistent_cfg);
|
|
199
|
+
|
|
200
|
+
// Remove and verify defaults return
|
|
201
|
+
client.remove_instance_ttl();
|
|
202
|
+
assert!(!client.has_instance_ttl());
|
|
203
|
+
assert_eq!(client.instance_ttl(), DEFAULT_INSTANCE_TTL);
|
|
204
|
+
|
|
205
|
+
// Remove persistent
|
|
206
|
+
client.remove_persistent_ttl();
|
|
207
|
+
assert!(!client.has_persistent_ttl());
|
|
208
|
+
assert_eq!(client.persistent_ttl(), DEFAULT_PERSISTENT_TTL);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
#[test]
|
|
212
|
+
fn test_ttl_config_data_frozen() {
|
|
213
|
+
let (_, _, _owner, client) = setup_contract();
|
|
214
|
+
|
|
215
|
+
assert!(!client.frozen());
|
|
216
|
+
|
|
217
|
+
client.set_frozen(&true);
|
|
218
|
+
assert!(client.frozen());
|
|
219
|
+
|
|
220
|
+
client.set_frozen(&false);
|
|
221
|
+
assert!(!client.frozen());
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
#[test]
|
|
225
|
+
fn test_ttl_config_data_independent_storage() {
|
|
226
|
+
let (_, _, _owner, client) = setup_contract();
|
|
227
|
+
|
|
228
|
+
let instance_cfg = TtlConfig::new(100, 200);
|
|
229
|
+
let persistent_cfg = TtlConfig::new(300, 400);
|
|
230
|
+
|
|
231
|
+
// Set each independently and verify others unchanged
|
|
232
|
+
client.set_instance_ttl(&instance_cfg);
|
|
233
|
+
assert_eq!(client.instance_ttl(), instance_cfg);
|
|
234
|
+
assert_eq!(client.persistent_ttl(), DEFAULT_PERSISTENT_TTL);
|
|
235
|
+
|
|
236
|
+
client.set_persistent_ttl(&persistent_cfg);
|
|
237
|
+
assert_eq!(client.instance_ttl(), instance_cfg);
|
|
238
|
+
assert_eq!(client.persistent_ttl(), persistent_cfg);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
#[test]
|
|
242
|
+
fn test_ttl_config_data_remove_all() {
|
|
243
|
+
let (_, _, _owner, client) = setup_contract();
|
|
244
|
+
|
|
245
|
+
let instance_cfg = TtlConfig::new(1000, 2000);
|
|
246
|
+
let persistent_cfg = TtlConfig::new(3000, 4000);
|
|
247
|
+
|
|
248
|
+
// Set all configs
|
|
249
|
+
client.set_instance_ttl(&instance_cfg);
|
|
250
|
+
client.set_persistent_ttl(&persistent_cfg);
|
|
251
|
+
|
|
252
|
+
// Verify all are set
|
|
253
|
+
assert!(client.has_instance_ttl());
|
|
254
|
+
assert!(client.has_persistent_ttl());
|
|
255
|
+
|
|
256
|
+
// Remove all
|
|
257
|
+
client.remove_instance_ttl();
|
|
258
|
+
client.remove_persistent_ttl();
|
|
259
|
+
|
|
260
|
+
// Verify all return to defaults
|
|
261
|
+
assert!(!client.has_instance_ttl());
|
|
262
|
+
assert!(!client.has_persistent_ttl());
|
|
263
|
+
assert_eq!(client.instance_ttl(), DEFAULT_INSTANCE_TTL);
|
|
264
|
+
assert_eq!(client.persistent_ttl(), DEFAULT_PERSISTENT_TTL);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
#[test]
|
|
268
|
+
fn test_ttl_config_data_remove_when_not_set() {
|
|
269
|
+
let (_, _, _owner, client) = setup_contract();
|
|
270
|
+
|
|
271
|
+
// Removing when not set should not panic
|
|
272
|
+
client.remove_instance_ttl();
|
|
273
|
+
client.remove_persistent_ttl();
|
|
274
|
+
|
|
275
|
+
// Should still return defaults
|
|
276
|
+
assert_eq!(client.instance_ttl(), DEFAULT_INSTANCE_TTL);
|
|
277
|
+
assert_eq!(client.persistent_ttl(), DEFAULT_PERSISTENT_TTL);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ============================================
|
|
281
|
+
// DefaultTtlConfigurable Tests - Basic Operations
|
|
282
|
+
// ============================================
|
|
283
|
+
|
|
284
|
+
#[test]
|
|
285
|
+
fn test_default_ttl_configurable_initial_state() {
|
|
286
|
+
let (_, _, _owner, client) = setup_contract();
|
|
287
|
+
|
|
288
|
+
let (instance, persistent) = client.configurable_ttl_configs();
|
|
289
|
+
assert!(instance.is_none());
|
|
290
|
+
assert!(persistent.is_none());
|
|
291
|
+
|
|
292
|
+
assert!(!client.is_ttl_configs_frozen());
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
#[test]
|
|
296
|
+
fn test_default_ttl_configurable_set_all() {
|
|
297
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
298
|
+
|
|
299
|
+
let instance_cfg = TtlConfig::new(1000, 2000);
|
|
300
|
+
let persistent_cfg = TtlConfig::new(3000, 4000);
|
|
301
|
+
|
|
302
|
+
let instance = Some(instance_cfg);
|
|
303
|
+
let persistent = Some(persistent_cfg);
|
|
304
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
305
|
+
|
|
306
|
+
assert_event(&env, &contract_id, TtlConfigsSet { instance, persistent });
|
|
307
|
+
|
|
308
|
+
let (instance, persistent) = client.configurable_ttl_configs();
|
|
309
|
+
assert_eq!(instance, Some(instance_cfg));
|
|
310
|
+
assert_eq!(persistent, Some(persistent_cfg));
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
#[test]
|
|
314
|
+
fn test_default_ttl_configurable_set_partial() {
|
|
315
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
316
|
+
|
|
317
|
+
let instance_cfg = TtlConfig::new(1000, 2000);
|
|
318
|
+
|
|
319
|
+
// Only set instance config
|
|
320
|
+
let instance = Some(instance_cfg);
|
|
321
|
+
let persistent = None;
|
|
322
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
323
|
+
assert_event(&env, &contract_id, TtlConfigsSet { instance, persistent });
|
|
324
|
+
|
|
325
|
+
let (instance, persistent) = client.configurable_ttl_configs();
|
|
326
|
+
assert_eq!(instance, Some(instance_cfg));
|
|
327
|
+
assert!(persistent.is_none());
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
#[test]
|
|
331
|
+
fn test_default_ttl_configurable_set_and_remove() {
|
|
332
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
333
|
+
|
|
334
|
+
let instance_cfg = TtlConfig::new(1000, 2000);
|
|
335
|
+
let persistent_cfg = TtlConfig::new(3000, 4000);
|
|
336
|
+
|
|
337
|
+
// Set configs
|
|
338
|
+
let instance = Some(instance_cfg);
|
|
339
|
+
let persistent = Some(persistent_cfg);
|
|
340
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
341
|
+
assert_eq!(client.configurable_ttl_configs(), (Some(instance_cfg), Some(persistent_cfg)));
|
|
342
|
+
|
|
343
|
+
// Remove only instance by passing None, keep persistent
|
|
344
|
+
let instance = None;
|
|
345
|
+
let persistent = Some(persistent_cfg);
|
|
346
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
347
|
+
assert_eq!(client.configurable_ttl_configs(), (None, Some(persistent_cfg)));
|
|
348
|
+
|
|
349
|
+
// Remove by passing None
|
|
350
|
+
let instance = None;
|
|
351
|
+
let persistent = None;
|
|
352
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
353
|
+
assert!(client.configurable_ttl_configs().0.is_none());
|
|
354
|
+
assert!(client.configurable_ttl_configs().1.is_none());
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// ============================================
|
|
358
|
+
// DefaultTtlConfigurable Tests - Freeze Operations
|
|
359
|
+
// ============================================
|
|
360
|
+
|
|
361
|
+
#[test]
|
|
362
|
+
fn test_default_ttl_configurable_freeze() {
|
|
363
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
364
|
+
|
|
365
|
+
assert!(!client.is_ttl_configs_frozen());
|
|
366
|
+
owner_freeze_ttl_configs(&env, &contract_id, &owner, &client);
|
|
367
|
+
assert_event(&env, &contract_id, TtlConfigsFrozen {});
|
|
368
|
+
assert!(client.is_ttl_configs_frozen());
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
#[test]
|
|
372
|
+
#[should_panic(expected = "Error(Contract, #1201)")]
|
|
373
|
+
fn test_default_ttl_configurable_set_when_frozen() {
|
|
374
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
375
|
+
|
|
376
|
+
owner_freeze_ttl_configs(&env, &contract_id, &owner, &client);
|
|
377
|
+
|
|
378
|
+
let instance_cfg = TtlConfig::new(1000, 2000);
|
|
379
|
+
let instance = Some(instance_cfg);
|
|
380
|
+
let persistent = None;
|
|
381
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
#[test]
|
|
385
|
+
#[should_panic(expected = "Error(Contract, #1202)")]
|
|
386
|
+
fn test_default_ttl_configurable_freeze_when_already_frozen() {
|
|
387
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
388
|
+
|
|
389
|
+
owner_freeze_ttl_configs(&env, &contract_id, &owner, &client);
|
|
390
|
+
assert_event(&env, &contract_id, TtlConfigsFrozen {});
|
|
391
|
+
owner_freeze_ttl_configs(&env, &contract_id, &owner, &client);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
#[test]
|
|
395
|
+
#[should_panic(expected = "Error(Auth, InvalidAction)")]
|
|
396
|
+
fn test_default_ttl_configurable_freeze_requires_auth() {
|
|
397
|
+
let (_env, _contract_id, _owner, client) = setup_contract();
|
|
398
|
+
|
|
399
|
+
// No `mock_auths` provided -> owner.require_auth() must fail.
|
|
400
|
+
client.configurable_freeze_ttl_configs();
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
#[test]
|
|
404
|
+
#[should_panic(expected = "Error(Auth, InvalidAction)")]
|
|
405
|
+
fn test_default_ttl_configurable_freeze_wrong_signer_fails() {
|
|
406
|
+
let (env, contract_id, _owner, client) = setup_contract();
|
|
407
|
+
let attacker = Address::generate(&env);
|
|
408
|
+
|
|
409
|
+
// Provide auth for the wrong address -> still must fail because stored owner is different.
|
|
410
|
+
mock_auth(&env, &contract_id, &attacker, "configurable_freeze_ttl_configs", ());
|
|
411
|
+
client.configurable_freeze_ttl_configs();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
#[test]
|
|
415
|
+
#[should_panic(expected = "Error(Contract, #1301)")]
|
|
416
|
+
fn test_default_ttl_configurable_freeze_when_owner_not_set() {
|
|
417
|
+
let env = Env::default();
|
|
418
|
+
let contract_id = env.register(TtlTestContract, ());
|
|
419
|
+
let client = TtlTestContractClient::new(&env, &contract_id);
|
|
420
|
+
|
|
421
|
+
let owner = Address::generate(&env);
|
|
422
|
+
|
|
423
|
+
// Even with auth, `require_owner_auth` should fail because no owner is set in storage.
|
|
424
|
+
mock_auth(&env, &contract_id, &owner, "configurable_freeze_ttl_configs", ());
|
|
425
|
+
client.configurable_freeze_ttl_configs();
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// ============================================
|
|
429
|
+
// DefaultTtlConfigurable Tests - Validation
|
|
430
|
+
// ============================================
|
|
431
|
+
|
|
432
|
+
#[test]
|
|
433
|
+
#[should_panic(expected = "Error(Contract, #1200)")]
|
|
434
|
+
fn test_default_ttl_configurable_invalid_instance_config() {
|
|
435
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
436
|
+
// threshold > extend_to is invalid
|
|
437
|
+
let invalid_cfg = TtlConfig::new(3000, 2000);
|
|
438
|
+
let instance = Some(invalid_cfg);
|
|
439
|
+
let persistent = None;
|
|
440
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
#[test]
|
|
444
|
+
#[should_panic(expected = "Error(Contract, #1200)")]
|
|
445
|
+
fn test_default_ttl_configurable_invalid_persistent_config() {
|
|
446
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
447
|
+
let invalid_cfg = TtlConfig::new(5000, 4000);
|
|
448
|
+
let instance = None;
|
|
449
|
+
let persistent = Some(invalid_cfg);
|
|
450
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
#[test]
|
|
454
|
+
#[should_panic(expected = "Error(Contract, #1200)")]
|
|
455
|
+
fn test_default_ttl_configurable_exceeds_max_ttl() {
|
|
456
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
457
|
+
let invalid_cfg = TtlConfig::new(1000, MAX_TTL + 1);
|
|
458
|
+
let instance = Some(invalid_cfg);
|
|
459
|
+
let persistent = None;
|
|
460
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
#[test]
|
|
464
|
+
fn test_default_ttl_configurable_invalid_does_not_partially_update() {
|
|
465
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
466
|
+
|
|
467
|
+
// Seed with an initial valid state.
|
|
468
|
+
let before_instance = TtlConfig::new(1000, 2000);
|
|
469
|
+
let before_persistent = TtlConfig::new(3000, 4000);
|
|
470
|
+
let instance = Some(before_instance);
|
|
471
|
+
let persistent = Some(before_persistent);
|
|
472
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
473
|
+
assert_eq!(client.configurable_ttl_configs(), (Some(before_instance), Some(before_persistent)));
|
|
474
|
+
|
|
475
|
+
// Attempt to update with one invalid config and one different valid config.
|
|
476
|
+
// This must fail and must not partially apply any changes.
|
|
477
|
+
let invalid_instance = TtlConfig::new(3000, 2000); // threshold > extend_to
|
|
478
|
+
let next_persistent = TtlConfig::new(3100, 4100);
|
|
479
|
+
let instance = Some(invalid_instance);
|
|
480
|
+
let persistent = Some(next_persistent);
|
|
481
|
+
mock_auth(&env, &contract_id, &owner, "configurable_set_ttl_configs", (&instance, &persistent));
|
|
482
|
+
assert_eq!(
|
|
483
|
+
client.try_configurable_set_ttl_configs(&instance, &persistent).unwrap_err().unwrap(),
|
|
484
|
+
TtlConfigurableError::InvalidTtlConfig.into()
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
// Ensure nothing changed.
|
|
488
|
+
assert_eq!(client.configurable_ttl_configs(), (Some(before_instance), Some(before_persistent)));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// ============================================================================
|
|
492
|
+
// Missing branches: owner auth & max-ttl bound behaviors
|
|
493
|
+
// ============================================================================
|
|
494
|
+
|
|
495
|
+
#[test]
|
|
496
|
+
#[should_panic(expected = "Error(Auth, InvalidAction)")]
|
|
497
|
+
fn test_default_ttl_configurable_set_requires_auth() {
|
|
498
|
+
let (_env, _contract_id, _owner, client) = setup_contract();
|
|
499
|
+
let instance = Some(TtlConfig::new(1000, 2000));
|
|
500
|
+
let persistent = None;
|
|
501
|
+
|
|
502
|
+
// No `mock_auths` provided -> owner.require_auth() must fail.
|
|
503
|
+
client.configurable_set_ttl_configs(&instance, &persistent);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
#[test]
|
|
507
|
+
#[should_panic(expected = "Error(Auth, InvalidAction)")]
|
|
508
|
+
fn test_default_ttl_configurable_set_wrong_signer_fails() {
|
|
509
|
+
let (env, contract_id, _owner, client) = setup_contract();
|
|
510
|
+
let attacker = Address::generate(&env);
|
|
511
|
+
|
|
512
|
+
let instance = Some(TtlConfig::new(1000, 2000));
|
|
513
|
+
let persistent = None;
|
|
514
|
+
|
|
515
|
+
// Provide auth for the wrong address -> still must fail because stored owner is different.
|
|
516
|
+
mock_auth(&env, &contract_id, &attacker, "configurable_set_ttl_configs", (&instance, &persistent));
|
|
517
|
+
client.configurable_set_ttl_configs(&instance, &persistent);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
#[test]
|
|
521
|
+
#[should_panic(expected = "Error(Contract, #1301)")]
|
|
522
|
+
fn test_default_ttl_configurable_set_when_owner_not_set() {
|
|
523
|
+
let env = Env::default();
|
|
524
|
+
let contract_id = env.register(TtlTestContract, ());
|
|
525
|
+
let client = TtlTestContractClient::new(&env, &contract_id);
|
|
526
|
+
|
|
527
|
+
let owner = Address::generate(&env);
|
|
528
|
+
let instance = Some(TtlConfig::new(1000, 2000));
|
|
529
|
+
let persistent = None;
|
|
530
|
+
|
|
531
|
+
// Even with auth, `require_owner_auth` should fail because no owner is set in storage.
|
|
532
|
+
mock_auth(&env, &contract_id, &owner, "configurable_set_ttl_configs", (&instance, &persistent));
|
|
533
|
+
client.configurable_set_ttl_configs(&instance, &persistent);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
#[test]
|
|
537
|
+
#[should_panic(expected = "Error(Contract, #1200)")]
|
|
538
|
+
fn test_default_ttl_configurable_exceeds_effective_max_ttl() {
|
|
539
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
540
|
+
|
|
541
|
+
let effective_max = u32::min(MAX_TTL, env.storage().max_ttl());
|
|
542
|
+
let invalid_extend_to = effective_max.checked_add(1).expect("effective_max at u32::MAX");
|
|
543
|
+
let instance = Some(TtlConfig::new(1, invalid_extend_to));
|
|
544
|
+
let persistent = None;
|
|
545
|
+
|
|
546
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// ============================================
|
|
550
|
+
// DefaultTtlConfigurable Tests - Boundary Values
|
|
551
|
+
// ============================================
|
|
552
|
+
|
|
553
|
+
#[test]
|
|
554
|
+
fn test_default_ttl_configurable_at_max_ttl() {
|
|
555
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
556
|
+
|
|
557
|
+
// Get the effective max TTL
|
|
558
|
+
let effective_max = u32::min(MAX_TTL, env.storage().max_ttl());
|
|
559
|
+
|
|
560
|
+
// extend_to == effective_max should be valid
|
|
561
|
+
let valid_cfg = TtlConfig::new(1000, effective_max);
|
|
562
|
+
let instance = Some(valid_cfg);
|
|
563
|
+
let persistent = None;
|
|
564
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
565
|
+
|
|
566
|
+
let (instance, _) = client.configurable_ttl_configs();
|
|
567
|
+
assert_eq!(instance, Some(valid_cfg));
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
#[test]
|
|
571
|
+
fn test_default_ttl_configurable_boundary_values() {
|
|
572
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
573
|
+
|
|
574
|
+
let effective_max = u32::min(MAX_TTL, env.storage().max_ttl());
|
|
575
|
+
|
|
576
|
+
// Zero threshold and extend_to
|
|
577
|
+
let cfg = TtlConfig::new(0, 0);
|
|
578
|
+
let instance = Some(cfg);
|
|
579
|
+
let persistent = None;
|
|
580
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
581
|
+
assert_eq!(client.configurable_ttl_configs().0, Some(cfg));
|
|
582
|
+
|
|
583
|
+
// Zero threshold, max extend_to
|
|
584
|
+
let cfg = TtlConfig::new(0, effective_max);
|
|
585
|
+
let instance = Some(cfg);
|
|
586
|
+
let persistent = None;
|
|
587
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
588
|
+
assert_eq!(client.configurable_ttl_configs().0, Some(cfg));
|
|
589
|
+
|
|
590
|
+
// Equal threshold and extend_to
|
|
591
|
+
let cfg = TtlConfig::new(1000, 1000);
|
|
592
|
+
let instance = Some(cfg);
|
|
593
|
+
let persistent = None;
|
|
594
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
595
|
+
assert_eq!(client.configurable_ttl_configs().0, Some(cfg));
|
|
596
|
+
}
|