Move.

Post

Share your knowledge.

Raju.
Raju158
Apr 06, 2025
Expert Q&A

How to test a function with a Receiving parameter in Sui?

I'm trying to test the receive_object function with a Receiving parameter in Sui based on the docs at this link. Initially, I created a test using the example, but I'm struggling with how to get the sent argument to be a Receiving type. I've also tried denoting the receiving type, but encountered errors. Could someone guide me on properly testing this function?

  • Move CLI
  • Move
0
4
Share
Comments
.

Answers

4
tomek.
Apr 6 2025, 19:22

If you are still facing issues with denoting the Receiving type in your tests, it might be helpful to test using the SUI CLI. With the CLI, you can easily specify type arguments using the --type-args flag, which could simplify your testing scenario.

0
Comments
.
Dominikus .
Apr 7 2025, 00:46

In some test scenarios, transferring objects directly as shared might not work as intended, especially if you get errors related to instantiation rights. Adjusting the way transactions are structured to facilitate object sharing initially, before attempting public receipt, could resolve these issues.

0
Comments
.
Caplec.
Apr 7 2025, 01:34

You may first need to structure your test in a way that transfers the object to the SharedObject using one TransactionBlock. In a subsequent TransactionBlock, you can call the module function for accepting, i.e., the function with Receiving<T>. This approach ensures that the object is first appropriately shared before attempting to receive it.

0
Comments
.
cod.
cod95
Apr 7 2025, 02:29

When transferring an object, using the public_transfer method is correct if you intend to give full ownership to the object, even if you are not specifically transferring it to a SharedObject. Both methods suit different use cases, so make sure you're using the one that aligns with your objective.

0
Comments
.

Do you know the answer?

Please log in and share it.

We use cookies to ensure you get the best experience on our website.
More info