Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions forc-plugins/forc-client/tests/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ async fn test_simple_deploy() {
node.kill().unwrap();
let expected = vec![DeployedPackage::Contract(DeployedContract {
id: ContractId::from_str(
"2fa29eaad02a2b3e090307cede8dd70f73d81315e05b10ba2ded19c8fcdad0f6",
"91c435d6cdb720db92097958163bc43dbc5c4acfbb3d98025039addb9e2da8bb",
)
.unwrap(),
proxy: None,
Expand Down Expand Up @@ -421,7 +421,7 @@ async fn test_deploy_submit_only() {
node.kill().unwrap();
let expected = vec![DeployedPackage::Contract(DeployedContract {
id: ContractId::from_str(
"2fa29eaad02a2b3e090307cede8dd70f73d81315e05b10ba2ded19c8fcdad0f6",
"91c435d6cdb720db92097958163bc43dbc5c4acfbb3d98025039addb9e2da8bb",
)
.unwrap(),
proxy: None,
Expand Down Expand Up @@ -468,12 +468,12 @@ async fn test_deploy_fresh_proxy() {
node.kill().unwrap();
let impl_contract = DeployedPackage::Contract(DeployedContract {
id: ContractId::from_str(
"2fa29eaad02a2b3e090307cede8dd70f73d81315e05b10ba2ded19c8fcdad0f6",
"91c435d6cdb720db92097958163bc43dbc5c4acfbb3d98025039addb9e2da8bb",
)
.unwrap(),
proxy: Some(
ContractId::from_str(
"9aaebaece00250296a1459e6ab1413083b69061d7942360880457c5002d9040d",
"212c0edca7ddbb762d93a2446083d94df2db059d1f41ad49807223e8249669e5",
)
.unwrap(),
),
Expand Down
8 changes: 4 additions & 4 deletions forc/tests/cli_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ fn test_forc_test_raw_logs() -> Result<(), rexpect::error::Error> {
// Assert that the output is correct
process.exp_string(" test test_log_4")?;
process.exp_string("raw logs:")?;
process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12416,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12408,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
process.exp_string(" test test_log_2")?;
process.exp_string("raw logs:")?;
process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12416,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12408,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;

process.process.exit()?;
Ok(())
Expand All @@ -77,12 +77,12 @@ fn test_forc_test_both_logs() -> Result<(), rexpect::error::Error> {
process.exp_string("decoded log values:")?;
process.exp_string("4, log rb: 1515152261580153489")?;
process.exp_string("raw logs:")?;
process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12416,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12408,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
process.exp_string(" test test_log_2")?;
process.exp_string("decoded log values:")?;
process.exp_string("2, log rb: 1515152261580153489")?;
process.exp_string("raw logs:")?;
process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12416,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12408,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?;
process.process.exit()?;
Ok(())
}
51 changes: 34 additions & 17 deletions sway-core/src/asm_generation/fuel/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,27 @@ impl FuelAsmBuilder<'_, '_> {
owning_span: None,
});

// Save the return value.
// Save the return value, if it is not of type unit.
let ret_reg = self.reg_seqr.next();
self.cur_bytecode.push(Op {
opcode: Either::Left(VirtualOp::MOVE(
ret_reg.clone(),
VirtualRegister::Constant(ConstantRegister::CallReturnValue),
)),
comment: "[call]: copy the return value".into(),
owning_span: None,
});
if !function.get_return_type(self.context).is_unit(self.context) {
self.cur_bytecode.push(Op {
opcode: Either::Left(VirtualOp::MOVE(
ret_reg.clone(),
VirtualRegister::Constant(ConstantRegister::CallReturnValue),
)),
comment: "[call]: copy the return value".into(),
owning_span: None,
});
} else {
self.cur_bytecode.push(Op {
opcode: Either::Left(VirtualOp::MOVE(
ret_reg.clone(),
VirtualRegister::Constant(ConstantRegister::Zero),
)),
comment: "[call]: return unit value".into(),
owning_span: None,
});
}
self.reg_map.insert(*instr_val, ret_reg);

Ok(())
Expand All @@ -210,15 +221,21 @@ impl FuelAsmBuilder<'_, '_> {
instr_val: &Value,
ret_val: &Value,
) -> Result<(), CompileError> {
// Move the result into the return value register.
// Move the result (if there is one) into the return value register.
let owning_span = self.md_mgr.val_to_span(self.context, *instr_val);
let ret_reg = self.value_to_register(ret_val)?;
self.cur_bytecode.push(Op::register_move(
VirtualRegister::Constant(ConstantRegister::CallReturnValue),
ret_reg,
"set return value",
owning_span,
));

if !ret_val
.get_type(self.context)
.is_some_and(|t| t.is_unit(self.context))
{
let ret_reg = self.value_to_register(ret_val)?;
self.cur_bytecode.push(Op::register_move(
VirtualRegister::Constant(ConstantRegister::CallReturnValue),
ret_reg,
"set return value",
owning_span,
));
}

// Jump to the end of the function.
let end_label = self
Expand Down
10 changes: 10 additions & 0 deletions test/src/e2e_vm_tests/test_programs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ specified, as a boolean value.

Some tests are only compatible with some build targets. To indicate this the `supported_targets` field may be specified, as an array value.

## unsupported_profiles

Some tests can only work with some profiles (release / debug). By default, tests are tested with all profiles.
In case of incompatibility, the `unsupported_profiles` field may be specified, as an array value.

## expected_warnings

Some tests can have valid warnings. To allow them, specify `expected_warnings`, which takes an integer arguments.
If more than these many number of warnings are emitted, the test fails.

## FileCheck for 'fail' tests

The tests in the `fail` category _must_ employ verification using pattern matching via the [FileCheck](https://docs.rs/filecheck/latest/filecheck/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ output:
Building test/src/e2e_vm_tests/test_programs/should_fail/language/const_generics
Compiling library std (sway-lib-std)
Compiling script const_generics (test/src/e2e_vm_tests/test_programs/should_fail/language/const_generics)
Finished debug [unoptimized + fuel] target(s) [120 B] in ???
Finished debug [unoptimized + fuel] target(s) [112 B] in ???
Loading
Loading