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

fix bug when writing to foreign proc #771

Merged
merged 1 commit into from
May 28, 2024
Merged

fix bug when writing to foreign proc #771

merged 1 commit into from
May 28, 2024

Conversation

brennanjl
Copy link
Collaborator

@brennanjl brennanjl commented May 28, 2024

This PR fixes several bugs, as well as adds better error messages and adds many tests for foreign procedures.

It fixes the bug found by @KwilLuke where writing data to a foreign procedure failed, as well as #770. It adds tests for both of them. It also adds many negative test cases to check for error messages thrown during runtime.

@brennanjl
Copy link
Collaborator Author

Moving back into draft to address #770, since it is a highly related issue.

@brennanjl brennanjl marked this pull request as draft May 28, 2024 14:20
@brennanjl brennanjl marked this pull request as ready for review May 28, 2024 20:20
Copy link
Contributor

@Yaiba Yaiba left a comment

Choose a reason for hiding this comment

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

LGTM, didn't go through the test cases, just skimmed

var initialData = map[string][]string{
"satoshi": {"hello world", "goodbye world", "buy $btc to grow laser eyes"},
"zeus": {"i am zeus", "i am the god of thunder", "i am the god of lightning"},
"wendys_drive_through_lady": {"hi how can I help you", "no I don't know what the federal reserve is", "sir this is a wendys"},
Copy link
Contributor

Choose a reason for hiding this comment

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

lol

parse/analyze.go Outdated
returns2, ok := p0.Call.Accept(p).([]*types.DataType)
if !ok {
p.errs.AddErr(p0.Call, ErrType, "expected function/procedure to return one or more variables")
} else if returns2, ok := returnVal.([]*types.DataType); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

probably should consider refactor this using switch?

parse/analyze.go Outdated

_, ok = e.Accept(s).(*returnsTable)
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like you can refactor this function switch

foreign: `foreign procedure do_something()`,
otherProc: `procedure call_foreign() public {
do_something['%s', 'delete_users']();
}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the expected result? expect no err and no outputs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nothing. No error and no outputs, as the procedure should be successful and it does not return anything.

wantErr: "requires 1 arg(s)",
},
{
name: "foreign procedure returns 1 arg, implementation returns none",
Copy link
Contributor

Choose a reason for hiding this comment

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

As you pointed out, the test name since here are less confusing. It would be better we change above test case name

@brennanjl
Copy link
Collaborator Author

Ok I addressed the changes @Yaiba

updated comment

fix bugs on foreign procedures

fix build tag

fixed act test

addressed gavins feedback

fix failing unit test
Yaiba
Yaiba previously approved these changes May 28, 2024
Copy link
Contributor

@Yaiba Yaiba left a comment

Choose a reason for hiding this comment

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

LGTM

@brennanjl brennanjl merged commit 933dca6 into main May 28, 2024
2 checks passed
@brennanjl brennanjl deleted the foreign-writes branch May 28, 2024 22:29
@jchappelow jchappelow added this to the v0.8.0 milestone Jun 7, 2024
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.

3 participants