Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init test porting #394

Merged
merged 22 commits into from
May 8, 2020
Merged

Init test porting #394

merged 22 commits into from
May 8, 2020

Conversation

RajarupanSampanthan
Copy link
Contributor

Summary of changes
Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes
310

Other information and links

Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're going to have to update from the address changes you pulled in (just removing the unwraps from id address creation) and make sure you run linter

Comment on lines +77 to +82
let _v = rt.send(
&entry.receiver,
entry.method_num,
&Serialized::default(),
&TokenAmount::from(0u8),
)?;
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert back to what it was, this is ignoring that error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was confused by this too. In the spec-actors repo they ignore any error or return values. I wasn't sure about why they did it but I just mimicked what they had. Are they doing something wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh, you're right. Interesting why that error is ignored, but I guess it makes sense. Possibly add a comment here to indicate that this is intentional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do let _ = instead of let _v = but yeah, so weird they dont use the error...

vm/actor/src/builtin/init/mod.rs Outdated Show resolved Hide resolved
vm/actor/src/builtin/init/mod.rs Outdated Show resolved Hide resolved
@@ -28,6 +28,7 @@ pub struct MockRuntime<'a, BS: BlockStore> {
pub id_addresses: HashMap<Address, Address>,
pub actor_code_cids: HashMap<Address, Cid>,
pub new_actor_addr: Option<Address>,
pub message: UnsignedMessage,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So about this, since all you need from this is caller, receiver, value_received and is currently storing that data twice (see above) you either need to remove the three fields above and handle those through the message type or update the runtime interface to not be hard coded UnsignedMessage and instead be an interface which returns those fields.

I think it makes sense to just do the former and add a TODO since that change is a bit more involved (cc: @ec2)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it makes sense. I was thinking we need to make a Message trait. In this case, I think this is the only way to make it work. The message() function returns a reference to a UnsignedMessage, so its not like we can construct the message using the caller, receiever, value_received inside of that function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear about that, it is a bit awkward to use, but only for the mock runtime. I'm not convinced that making it generic is objectively better, can just handle those things through an unsigned message in the mock rt since it's only used for testing, but maybe yeah a bit clunky still.

Having the message trait makes the mockrt impl more straightforward, at the cost of the actual runtime being unnecessarily complicated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I was thinking about it from the perspective of the MockRt. I dont expect us to be building any more runtimes anyways.

vm/actor/tests/common/mod.rs Outdated Show resolved Hide resolved
vm/actor/tests/common/mod.rs Outdated Show resolved Hide resolved
vm/actor/tests/common/mod.rs Outdated Show resolved Hide resolved
vm/actor/tests/common/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small things

vm/actor/src/builtin/init/mod.rs Outdated Show resolved Hide resolved
vm/actor/src/builtin/init/mod.rs Outdated Show resolved Hide resolved
vm/actor/tests/common/mod.rs Outdated Show resolved Hide resolved
vm/actor/tests/common/mod.rs Outdated Show resolved Hide resolved
vm/src/error.rs Outdated Show resolved Hide resolved
vm/actor/tests/common/mod.rs Outdated Show resolved Hide resolved
vm/actor/tests/common/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@austinabell austinabell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last couple changes then good to go !

@@ -90,6 +90,7 @@ impl Actor {
rt.create_actor(&params.code_cid, &id_address)?;

// Invoke constructor

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change

Comment on lines 80 to 85
// UnsignedMessage::builder()
// .to(receiver.clone())
// .from(Address::default())
// .value(0u8.into())
// .build()
// .unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// UnsignedMessage::builder()
// .to(receiver.clone())
// .from(Address::default())
// .value(0u8.into())
// .build()
// .unwrap(),

Comment on lines 305 to 310
rt.message = UnsignedMessage::builder()
.to(rt.message.to().clone())
.from(rt.message.from().clone())
.value(rt.message.value().clone())
.build()
.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rt.message = UnsignedMessage::builder()
.to(rt.message.to().clone())
.from(rt.message.from().clone())
.value(rt.message.value().clone())
.build()
.unwrap();

Comment on lines 322 to 328
let ret = match ret {
Ok(v) => Ok(v),
Err(e) => {
rt.state = prev_state;
Err(e)
}
};
Copy link
Contributor

@austinabell austinabell May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let ret = match ret {
Ok(v) => Ok(v),
Err(e) => {
rt.state = prev_state;
Err(e)
}
};
if ret.is_err() {
rt.state = prev_state;
}

@RajarupanSampanthan RajarupanSampanthan merged commit a048f25 into master May 8, 2020
@RajarupanSampanthan RajarupanSampanthan deleted the init_test_porting branch May 8, 2020 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants