Skip to content

Commit

Permalink
fix some comments
Browse files Browse the repository at this point in the history
Signed-off-by: Cyrill Leutwiler <[email protected]>
  • Loading branch information
xermicus committed Dec 10, 2024
1 parent a5d7b72 commit 43dbd32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion substrate/frame/revive/fixtures/contracts/call_data_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! This calls another contract as passed as its account id.
//! This uses the call data load API to first the first input byte.
//! This single input byte is used as the offset for a second call
//! to the call data load API.
//! The output of the second API call is returned.
#![no_std]
#![no_main]

Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/revive/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4417,15 +4417,15 @@ fn call_data_load_api_works() {
let Contract { addr, .. } =
builder::bare_instantiate(Code::Upload(code)).build_and_unwrap_contract();

// Call the contract: It reads a whole U256 for the offset
// and then return what call data load returns with this offset.
// Call the contract: It reads a byte for the offset and then returns
// what call data load returned using this byte as the offset.
let input = (2u8, U256::from(255).to_big_endian()).encode();
let received = builder::bare_call(addr).data(input).build().result.unwrap();
assert_eq!(received.flags, ReturnFlags::empty());
assert_eq!(U256::from_little_endian(&received.data), U256::from(65280));

// OOB case
let input = (2u8).encode();
let input = (42u8).encode();
let received = builder::bare_call(addr).data(input).build().result.unwrap();
assert_eq!(received.flags, ReturnFlags::empty());
assert_eq!(U256::from_little_endian(&received.data), U256::zero());
Expand Down

0 comments on commit 43dbd32

Please sign in to comment.