Skip to content

Fix issue #1841#2140

Merged
fubuloubu merged 2 commits into
vyperlang:masterfrom
saikat041:fix-#1814
Sep 3, 2020
Merged

Fix issue #1841#2140
fubuloubu merged 2 commits into
vyperlang:masterfrom
saikat041:fix-#1814

Conversation

@saikat041

Copy link
Copy Markdown
Contributor

What I did

Fixed issue: ABI issue with bytes and string arrays inside tuples #1841

How I did it

I modified below line:

if sub.args and len(sub.args[0].args) > 0 and sub.args[0].args[0].value == "call":

In this line, we are checking if the return expression is an external function call, and is it is an external functional we are not encoding the data as the return from the external call is already encoded. Here we forgot to add the condition
sub.args[0].args[0].value == "staticcall"

How to verify it

Run below test case:

def test_bytes_inside_tuple(get_contract):
    code = """
@external
def test_return() -> (String[6], uint256):
    return "potato", 42
    """
    c1 = get_contract(code)

    code = """
interface jsonabi:
    def test_return() -> (String[6], uint256): view

@external
def test_values(a: address) -> (String[6], uint256):
    return jsonabi(a).test_return()
    """

    c2 = get_contract(code)
    assert c2.test_values(c1.address) == ["potato", 42]

@codecov-commenter

codecov-commenter commented Sep 3, 2020

Copy link
Copy Markdown

Codecov Report

Merging #2140 into master will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2140      +/-   ##
==========================================
+ Coverage   84.90%   84.95%   +0.04%     
==========================================
  Files          83       83              
  Lines        8333     8333              
  Branches     2012     2012              
==========================================
+ Hits         7075     7079       +4     
+ Misses        755      752       -3     
+ Partials      503      502       -1     
Impacted Files Coverage Δ
vyper/codegen/return_.py 100.00% <100.00%> (+8.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3eb9e7a...66b1472. Read the comment docs.

@fubuloubu

Copy link
Copy Markdown
Contributor

This fix looks great! Saw your comment here #1841 (comment), @iamdefinitelyahuman and I were considering re-architecting the test suite at some point to be easier to understand where to put things. Find a good place for it for now, and we'll move it around later!

@iamdefinitelyahuman

Copy link
Copy Markdown
Contributor

Based on how we're looking to re-organize the tests, I'd place the test file in tests/functional/codegen/

@fubuloubu fubuloubu merged commit ce88755 into vyperlang:master Sep 3, 2020
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