@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,76 @@
|
|
|
1
|
+
use proc_macro2::TokenStream;
|
|
2
|
+
use quote::quote;
|
|
3
|
+
use syn::ItemStruct;
|
|
4
|
+
|
|
5
|
+
/// Generates the upgradeable implementation from the `#[upgradeable]` attribute macro.
|
|
6
|
+
///
|
|
7
|
+
/// This function generates the implementation of the `Upgradeable` trait for a
|
|
8
|
+
/// given contract type, enabling the contract to be upgraded by replacing its
|
|
9
|
+
/// WASM bytecode with migration support.
|
|
10
|
+
///
|
|
11
|
+
/// # Behavior
|
|
12
|
+
///
|
|
13
|
+
/// - Implements the `upgrade` and `migrate` functions with owner-based access control.
|
|
14
|
+
/// - Sets the contract crate version as `"binver"` metadata using
|
|
15
|
+
/// `soroban_sdk::contractmeta!`. Gets the crate version via the env variable
|
|
16
|
+
/// `CARGO_PKG_VERSION` which corresponds to the "version" attribute in
|
|
17
|
+
/// Cargo.toml. If no such attribute or if it is "0.0.0", skips this step.
|
|
18
|
+
/// - Requires the contract to implement `Ownable` and `UpgradeableInternal` traits.
|
|
19
|
+
///
|
|
20
|
+
/// # Example
|
|
21
|
+
/// ```ignore
|
|
22
|
+
/// #[ownable]
|
|
23
|
+
/// #[upgradeable]
|
|
24
|
+
/// pub struct MyContract;
|
|
25
|
+
/// ```
|
|
26
|
+
pub fn generate_upgradeable_impl(input: TokenStream) -> TokenStream {
|
|
27
|
+
let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
|
|
28
|
+
let name = &item_struct.ident;
|
|
29
|
+
|
|
30
|
+
let binver = set_binver_from_env();
|
|
31
|
+
|
|
32
|
+
let upgradeable_impl = quote! {
|
|
33
|
+
use utils::upgradeable::Upgradeable as _;
|
|
34
|
+
|
|
35
|
+
#binver
|
|
36
|
+
|
|
37
|
+
// Type alias to avoid path complexity in contractimpl
|
|
38
|
+
type MigrationData = <#name as utils::upgradeable::UpgradeableInternal>::MigrationData;
|
|
39
|
+
|
|
40
|
+
/// Implement the Upgradeable trait for the contract.
|
|
41
|
+
#[common_macros::contract_impl]
|
|
42
|
+
impl utils::upgradeable::Upgradeable for #name {
|
|
43
|
+
#[common_macros::only_owner]
|
|
44
|
+
fn upgrade(env: &soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>) {
|
|
45
|
+
utils::upgradeable::upgrade(env, new_wasm_hash)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[common_macros::only_owner]
|
|
49
|
+
fn migrate(env: &soroban_sdk::Env, migration_data: &MigrationData) {
|
|
50
|
+
utils::upgradeable::migrate::<Self>(env, migration_data)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
quote! {
|
|
56
|
+
#item_struct
|
|
57
|
+
#upgradeable_impl
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Sets the value of the environment variable `CARGO_PKG_VERSION` as `binver`
|
|
62
|
+
/// in the wasm binary metadata. This env variable corresponds to the attribute
|
|
63
|
+
/// "version" in Cargo.toml. If the attribute is missing or if it is "0.0.0",
|
|
64
|
+
/// the function does nothing.
|
|
65
|
+
fn set_binver_from_env() -> TokenStream {
|
|
66
|
+
// However when "version" is missing from Cargo.toml,
|
|
67
|
+
// the following does not return error, but Ok("0.0.0")
|
|
68
|
+
let version = std::env::var("CARGO_PKG_VERSION");
|
|
69
|
+
|
|
70
|
+
match version {
|
|
71
|
+
Ok(v) if v != "0.0.0" => {
|
|
72
|
+
quote! { soroban_sdk::contractmeta!(key = "binver", val = #v); }
|
|
73
|
+
}
|
|
74
|
+
_ => quote! {},
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -16,12 +16,13 @@ use crate::{
|
|
|
16
16
|
FeeRecipient, FeesAndPacket, IMessagingComposer, LayerZeroReceiverClient, MessageLibClient, MessageLibType,
|
|
17
17
|
MessagingParams, OutboundPacket, ResolvedLibrary, SendLibClient, SetConfigParam, Timeout,
|
|
18
18
|
};
|
|
19
|
-
use common_macros::{contract_impl, only_owner, ttl_configurable};
|
|
19
|
+
use common_macros::{contract_impl, only_owner, ownable, ttl_configurable};
|
|
20
20
|
use soroban_sdk::{assert_with_error, contract, token::TokenClient, vec, Address, Bytes, BytesN, Env, Vec};
|
|
21
21
|
use utils::option_ext::OptionExt;
|
|
22
22
|
|
|
23
23
|
#[contract]
|
|
24
24
|
#[ttl_configurable]
|
|
25
|
+
#[ownable]
|
|
25
26
|
pub struct EndpointV2;
|
|
26
27
|
|
|
27
28
|
#[contract_impl]
|
|
@@ -296,6 +297,29 @@ impl EndpointV2 {
|
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
|
|
300
|
+
// ============================================================================
|
|
301
|
+
// Test-only Functions
|
|
302
|
+
// ============================================================================
|
|
303
|
+
|
|
304
|
+
#[cfg(test)]
|
|
305
|
+
mod test {
|
|
306
|
+
use super::*;
|
|
307
|
+
|
|
308
|
+
impl EndpointV2 {
|
|
309
|
+
/// Test-only wrapper for build_outbound_packet to enable testing.
|
|
310
|
+
pub fn build_outbound_packet_for_test(
|
|
311
|
+
env: &Env,
|
|
312
|
+
sender: &Address,
|
|
313
|
+
dst_eid: u32,
|
|
314
|
+
receiver: &BytesN<32>,
|
|
315
|
+
message: &Bytes,
|
|
316
|
+
nonce: u64,
|
|
317
|
+
) -> OutboundPacket {
|
|
318
|
+
Self::build_outbound_packet(env, sender, dst_eid, receiver, message, nonce)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
299
323
|
// ============================================================================
|
|
300
324
|
// Include Modules
|
|
301
325
|
// ============================================================================
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
use soroban_sdk::token::TokenClient;
|
|
2
|
+
use soroban_sdk::{
|
|
3
|
+
testutils::{Address as _, MockAuth, MockAuthInvoke},
|
|
4
|
+
token::StellarAssetClient,
|
|
5
|
+
vec, Address, Bytes, BytesN, Env, IntoVal, Val, Vec,
|
|
6
|
+
};
|
|
7
|
+
|
|
1
8
|
use crate::{
|
|
2
9
|
endpoint_v2::{EndpointV2, EndpointV2Client},
|
|
10
|
+
storage,
|
|
3
11
|
tests::mock::{
|
|
4
12
|
MockMessageLib, MockMessageLibClient, MockReceiveLib, MockReceiveLibClient, MockSendLib, MockSendLibClient,
|
|
5
13
|
},
|
|
6
14
|
MessageLibType,
|
|
7
15
|
};
|
|
8
|
-
use soroban_sdk::{
|
|
9
|
-
testutils::{Address as _, MockAuth, MockAuthInvoke},
|
|
10
|
-
token::StellarAssetClient,
|
|
11
|
-
Address, Env, IntoVal, Val, Vec,
|
|
12
|
-
};
|
|
13
16
|
|
|
14
17
|
pub struct TestSetup<'a> {
|
|
15
18
|
pub eid: u32,
|
|
@@ -38,10 +41,10 @@ pub fn setup<'a>() -> TestSetup<'a> {
|
|
|
38
41
|
|
|
39
42
|
// Deploy the endpoint contract
|
|
40
43
|
let contract_id = env.register(EndpointV2, (&owner,));
|
|
41
|
-
let
|
|
42
|
-
let eid =
|
|
44
|
+
let endpoint_client = EndpointV2Client::new(&env, &contract_id);
|
|
45
|
+
let eid = endpoint_client.eid();
|
|
43
46
|
|
|
44
|
-
TestSetup { eid, endpoint_client
|
|
47
|
+
TestSetup { eid, endpoint_client, env, owner, contract_id, native_token_client, zro_token_client }
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
impl<'a> TestSetup<'a> {
|
|
@@ -73,6 +76,50 @@ impl<'a> TestSetup<'a> {
|
|
|
73
76
|
self.zro_token_client.mint(to, &amount);
|
|
74
77
|
}
|
|
75
78
|
|
|
79
|
+
/// Helper function to transfer native tokens with proper authorization
|
|
80
|
+
pub fn transfer_native(&self, from: &Address, to: &Address, amount: i128) {
|
|
81
|
+
let env = &self.env;
|
|
82
|
+
let token_client = TokenClient::new(env, &self.native_token_client.address);
|
|
83
|
+
env.mock_auths(&[MockAuth {
|
|
84
|
+
address: from,
|
|
85
|
+
invoke: &MockAuthInvoke {
|
|
86
|
+
contract: &self.native_token_client.address,
|
|
87
|
+
fn_name: "transfer",
|
|
88
|
+
args: (from, to, &amount).into_val(env),
|
|
89
|
+
sub_invokes: &[],
|
|
90
|
+
},
|
|
91
|
+
}]);
|
|
92
|
+
token_client.transfer(from, to, &amount);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// Helper function to transfer ZRO tokens with proper authorization
|
|
96
|
+
pub fn transfer_zro(&self, from: &Address, to: &Address, amount: i128) {
|
|
97
|
+
let env = &self.env;
|
|
98
|
+
let token_client = TokenClient::new(env, &self.zro_token_client.address);
|
|
99
|
+
env.mock_auths(&[MockAuth {
|
|
100
|
+
address: from,
|
|
101
|
+
invoke: &MockAuthInvoke {
|
|
102
|
+
contract: &self.zro_token_client.address,
|
|
103
|
+
fn_name: "transfer",
|
|
104
|
+
args: (from, to, &amount).into_val(env),
|
|
105
|
+
sub_invokes: &[],
|
|
106
|
+
},
|
|
107
|
+
}]);
|
|
108
|
+
token_client.transfer(from, to, &amount);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// Helper to mint native tokens to `from` and transfer them to the endpoint contract.
|
|
112
|
+
pub fn fund_endpoint_with_native(&self, from: &Address, amount: i128) {
|
|
113
|
+
self.mint_native(from, amount);
|
|
114
|
+
self.transfer_native(from, &self.endpoint_client.address, amount);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/// Helper to mint ZRO tokens to `from` and transfer them to the endpoint contract.
|
|
118
|
+
pub fn fund_endpoint_with_zro(&self, from: &Address, amount: i128) {
|
|
119
|
+
self.mint_zro(from, amount);
|
|
120
|
+
self.transfer_zro(from, &self.endpoint_client.address, amount);
|
|
121
|
+
}
|
|
122
|
+
|
|
76
123
|
// Helper to mock owner auth for common operations
|
|
77
124
|
pub fn mock_owner_auth<T: IntoVal<Env, Vec<Val>>>(&self, fn_name: &str, args: T) {
|
|
78
125
|
self.env.mock_auths(&[MockAuth {
|
|
@@ -128,4 +175,124 @@ impl<'a> TestSetup<'a> {
|
|
|
128
175
|
lib_client.setup(&supported_eids);
|
|
129
176
|
lib
|
|
130
177
|
}
|
|
178
|
+
|
|
179
|
+
/// Helper to setup (or rotate) a default receive library for a source endpoint with a grace period.
|
|
180
|
+
/// Creates a mock receive library, registers it, and sets it as the default for the given src_eid.
|
|
181
|
+
pub fn setup_default_receive_lib(&self, src_eid: u32, grace_period: u64) -> Address {
|
|
182
|
+
let receive_lib = self.setup_mock_receive_lib(vec![&self.env, src_eid]);
|
|
183
|
+
|
|
184
|
+
self.register_library_with_auth(&receive_lib);
|
|
185
|
+
self.set_default_receive_library_with_auth(src_eid, &receive_lib, grace_period);
|
|
186
|
+
|
|
187
|
+
receive_lib
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
pub fn set_default_receive_library_with_auth(&self, src_eid: u32, receive_lib: &Address, grace_period: u64) {
|
|
191
|
+
self.mock_owner_auth("set_default_receive_library", (&src_eid, receive_lib, &grace_period));
|
|
192
|
+
self.endpoint_client.set_default_receive_library(&src_eid, receive_lib, &grace_period);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
pub fn set_default_send_library_with_auth(&self, dst_eid: u32, send_lib: &Address) {
|
|
196
|
+
self.mock_owner_auth("set_default_send_library", (&dst_eid, send_lib));
|
|
197
|
+
self.endpoint_client.set_default_send_library(&dst_eid, send_lib);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/// Helper to setup a default send library for a destination endpoint.
|
|
201
|
+
/// Creates a mock send library, registers it, and sets it as the default for the given dst_eid.
|
|
202
|
+
pub fn setup_default_send_lib(&self, dst_eid: u32, native_fee: i128, zro_fee: i128) -> (Address, Address) {
|
|
203
|
+
let fee_recipient = Address::generate(&self.env);
|
|
204
|
+
let send_lib = self.setup_mock_send_lib(vec![&self.env, dst_eid], native_fee, zro_fee, fee_recipient.clone());
|
|
205
|
+
|
|
206
|
+
self.register_library_with_auth(&send_lib);
|
|
207
|
+
|
|
208
|
+
self.set_default_send_library_with_auth(dst_eid, &send_lib);
|
|
209
|
+
|
|
210
|
+
(send_lib, fee_recipient)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/// Helper to setup ZRO token on the endpoint
|
|
214
|
+
pub fn setup_zro_with_auth(&self) {
|
|
215
|
+
self.mock_owner_auth("set_zro", (&self.zro_token_client.address,));
|
|
216
|
+
self.endpoint_client.set_zro(&self.zro_token_client.address);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/// Helper to register a message library as the contract owner (mocks owner auth + performs call).
|
|
220
|
+
pub fn register_library_with_auth(&self, lib: &Address) {
|
|
221
|
+
self.mock_owner_auth("register_library", (lib,));
|
|
222
|
+
self.endpoint_client.register_library(lib);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/// Helper to setup a new custom receive library for an OApp with a grace period.
|
|
226
|
+
/// Returns the newly created receive library address.
|
|
227
|
+
pub fn setup_receive_library(
|
|
228
|
+
&self,
|
|
229
|
+
caller: &Address,
|
|
230
|
+
receiver: &Address,
|
|
231
|
+
src_eid: u32,
|
|
232
|
+
grace_period: u64,
|
|
233
|
+
) -> Address {
|
|
234
|
+
let lib = self.setup_mock_receive_lib(vec![&self.env, src_eid]);
|
|
235
|
+
self.register_library_with_auth(&lib);
|
|
236
|
+
self.set_receive_library_with_auth(caller, receiver, src_eid, &Some(lib.clone()), grace_period);
|
|
237
|
+
lib
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
pub fn set_receive_library_with_auth(
|
|
241
|
+
&self,
|
|
242
|
+
caller: &Address,
|
|
243
|
+
receiver: &Address,
|
|
244
|
+
src_eid: u32,
|
|
245
|
+
new_lib: &Option<Address>,
|
|
246
|
+
grace_period: u64,
|
|
247
|
+
) {
|
|
248
|
+
self.mock_auth(caller, "set_receive_library", (caller, receiver, src_eid, new_lib, grace_period));
|
|
249
|
+
self.endpoint_client.set_receive_library(caller, receiver, &src_eid, new_lib, &grace_period);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
pub fn set_send_library_with_auth(
|
|
253
|
+
&self,
|
|
254
|
+
caller: &Address,
|
|
255
|
+
sender: &Address,
|
|
256
|
+
dst_eid: u32,
|
|
257
|
+
new_lib: &Option<Address>,
|
|
258
|
+
) {
|
|
259
|
+
self.mock_auth(caller, "set_send_library", (caller, sender, dst_eid, new_lib));
|
|
260
|
+
self.endpoint_client.set_send_library(caller, sender, &dst_eid, new_lib);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
pub fn set_delegate_with_auth(&self, oapp: &Address, delegate: &Option<Address>) {
|
|
264
|
+
self.mock_auth(oapp, "set_delegate", (oapp, delegate));
|
|
265
|
+
self.endpoint_client.set_delegate(oapp, delegate);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
pub fn send_compose_with_auth(&self, from: &Address, to: &Address, guid: &BytesN<32>, index: u32, message: &Bytes) {
|
|
269
|
+
self.mock_auth(from, "send_compose", (from, to, guid, &index, message));
|
|
270
|
+
self.endpoint_client.send_compose(from, to, guid, &index, message);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
pub fn set_lazy_inbound_nonce(&self, receiver: &Address, src_eid: u32, sender: &BytesN<32>, lazy_nonce: u64) {
|
|
274
|
+
let env = &self.env;
|
|
275
|
+
let endpoint_client = &self.endpoint_client;
|
|
276
|
+
env.as_contract(&endpoint_client.address, || {
|
|
277
|
+
storage::EndpointStorage::set_lazy_inbound_nonce(env, receiver, src_eid, sender, &lazy_nonce)
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/// Helper to mark an inbound message as verified by writing its payload hash into storage.
|
|
282
|
+
///
|
|
283
|
+
/// This is a test-only utility used by multiple messaging channel test suites.
|
|
284
|
+
pub fn inbound_as_verified(
|
|
285
|
+
&self,
|
|
286
|
+
receiver: &Address,
|
|
287
|
+
src_eid: u32,
|
|
288
|
+
sender: &BytesN<32>,
|
|
289
|
+
nonce: u64,
|
|
290
|
+
payload_hash: &BytesN<32>,
|
|
291
|
+
) {
|
|
292
|
+
let env = &self.env;
|
|
293
|
+
let endpoint_client = &self.endpoint_client;
|
|
294
|
+
env.as_contract(&endpoint_client.address, || {
|
|
295
|
+
EndpointV2::inbound(env, receiver, src_eid, sender, nonce, payload_hash)
|
|
296
|
+
});
|
|
297
|
+
}
|
|
131
298
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
use soroban_sdk::{testutils::Address as _, Address, Bytes, BytesN};
|
|
2
|
+
|
|
3
|
+
use crate::{endpoint_v2::EndpointV2, tests::endpoint_setup::setup, util::compute_guid};
|
|
4
|
+
|
|
5
|
+
#[test]
|
|
6
|
+
fn test_build_outbound_packet_basic() {
|
|
7
|
+
let context = setup();
|
|
8
|
+
let env = &context.env;
|
|
9
|
+
let endpoint_addr = &context.endpoint_client.address;
|
|
10
|
+
|
|
11
|
+
let sender = Address::generate(env);
|
|
12
|
+
let dst_eid = 2u32;
|
|
13
|
+
let receiver = BytesN::from_array(env, &[1u8; 32]);
|
|
14
|
+
let message = Bytes::from_array(env, &[1, 2, 3, 4]);
|
|
15
|
+
let nonce = 1u64;
|
|
16
|
+
|
|
17
|
+
let packet = env.as_contract(endpoint_addr, || {
|
|
18
|
+
EndpointV2::build_outbound_packet_for_test(env, &sender, dst_eid, &receiver, &message, nonce)
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Verify packet fields
|
|
22
|
+
assert_eq!(packet.nonce, nonce);
|
|
23
|
+
assert_eq!(packet.src_eid, context.eid);
|
|
24
|
+
assert_eq!(packet.sender, sender);
|
|
25
|
+
assert_eq!(packet.dst_eid, dst_eid);
|
|
26
|
+
assert_eq!(packet.receiver, receiver);
|
|
27
|
+
assert_eq!(packet.message, message);
|
|
28
|
+
assert_eq!(packet.guid.len(), 32);
|
|
29
|
+
|
|
30
|
+
// Verify GUID is computed correctly
|
|
31
|
+
let expected_guid = compute_guid(env, nonce, context.eid, &sender, dst_eid, &receiver);
|
|
32
|
+
assert_eq!(packet.guid, expected_guid);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#[test]
|
|
36
|
+
fn test_build_outbound_packet_empty_message() {
|
|
37
|
+
let context = setup();
|
|
38
|
+
let env = &context.env;
|
|
39
|
+
let endpoint_addr = &context.endpoint_client.address;
|
|
40
|
+
|
|
41
|
+
let sender = Address::generate(env);
|
|
42
|
+
let dst_eid = 2u32;
|
|
43
|
+
let receiver = BytesN::from_array(env, &[1u8; 32]);
|
|
44
|
+
let message = Bytes::new(env);
|
|
45
|
+
let nonce = 1u64;
|
|
46
|
+
|
|
47
|
+
let packet = env.as_contract(endpoint_addr, || {
|
|
48
|
+
EndpointV2::build_outbound_packet_for_test(env, &sender, dst_eid, &receiver, &message, nonce)
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Should handle empty message correctly
|
|
52
|
+
assert_eq!(packet.message.len(), 0);
|
|
53
|
+
assert_eq!(packet.nonce, nonce);
|
|
54
|
+
assert_eq!(packet.guid.len(), 32);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[test]
|
|
58
|
+
fn test_build_outbound_packet_large_message() {
|
|
59
|
+
let context = setup();
|
|
60
|
+
let env = &context.env;
|
|
61
|
+
let endpoint_addr = &context.endpoint_client.address;
|
|
62
|
+
|
|
63
|
+
let sender = Address::generate(env);
|
|
64
|
+
let dst_eid = 2u32;
|
|
65
|
+
let receiver = BytesN::from_array(env, &[1u8; 32]);
|
|
66
|
+
let large_message = Bytes::from_array(env, &[0u8; 1000]);
|
|
67
|
+
let nonce = 1u64;
|
|
68
|
+
|
|
69
|
+
let packet = env.as_contract(endpoint_addr, || {
|
|
70
|
+
EndpointV2::build_outbound_packet_for_test(env, &sender, dst_eid, &receiver, &large_message, nonce)
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Should handle large message correctly
|
|
74
|
+
assert_eq!(packet.message.len(), 1000);
|
|
75
|
+
assert_eq!(packet.message, large_message);
|
|
76
|
+
}
|