Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Conversation

@mlouielu
Copy link
Contributor

@mlouielu mlouielu commented Nov 9, 2017

Issue: #92

pycurl.Curl.absorb:
Add offset and length

pycurl.Curl.squeeze:
Add offset

sequeeze not added with length, is because it will only
copy one hash to trits, therefore no need to add length

@todofixthis
Copy link
Contributor

Thanks @mlouielu ! I will take a look at this over the weekend.

@todofixthis todofixthis changed the base branch from master to develop November 11, 2017 20:21
Copy link
Contributor

@todofixthis todofixthis left a comment

Choose a reason for hiding this comment

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

Hey @mlouielu this is looking pretty good!

I changed the target branch to develop, and I requested a few changes; mostly minor.

'offset': offset,
'length': length,
},
)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

offset += HASH_LENGTH

def squeeze(self, trits):
def squeeze(self, trits, offset=0):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should squeeze also have a length argument?

In practice, it seems that this argument is always HASH_LENGTH, but the other libraries do support it. Examples:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, but in real case, this doesn't use without 243 (HASH_LENGTH)

from unittest import TestCase

from iota import TryteString
from iota.crypto.pycurl import Curl
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you change this to from iota.crypto import Curl? That way, I can repurpose these tests for the C extension.

More info:



class TestCurl(TestCase):
def test_correct_first(self):
Copy link
Contributor

@todofixthis todofixthis Nov 11, 2017

Choose a reason for hiding this comment

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

Could you add a docstring to each unit test, describing the situation it is testing? The test names are a good start, but a little extra documentation describing the context for each test will go a long way.

for i in range(6):
curl.reset()
curl.absorb(trits, i * 243, (i + 1) * 243)
curl.squeeze(trits, i * 243)
Copy link
Contributor

Choose a reason for hiding this comment

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

This test looks very specific. Is it mimicking a real-world use case?

Unit tests also serve as documentation; if you add some comments explaining what real-world situation this test is simulating, it will help users to better understand what they can accomplish with the library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only use in ISS and ISSInplace, add the source code link in docstring.

@todofixthis
Copy link
Contributor

Hey @mlouielu I feel like this PR is almost ready to merge. I've requested a few changes, but they're mostly minor stuff, documentation and such. Let me know if you have any questions, or if I can provide additional info.

@mlouielu
Copy link
Contributor Author

mlouielu commented Jan 8, 2018

I'll find some time these days to make sure this PR fits your guide.

@todofixthis
Copy link
Contributor

Thanks Louie!

pycurl.Curl.absorb:
    Add offset and length

pycurl.Curl.squeeze:
    Add offset

    sequeeze not added with length, is because it will only
    copy one hash to trits, therefore no need to add length
@mlouielu mlouielu force-pushed the add_pycurl_offset_length branch from f08fc0a to 0245bc8 Compare January 10, 2018 04:05
@todofixthis
Copy link
Contributor

Hey Louie! Thanks for working on this! I will take a look this weekend and follow up.

Copy link
Contributor

@todofixthis todofixthis left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks Louie!!

@todofixthis todofixthis merged commit df4714e into iotaledger-archive:develop Jan 13, 2018
marko-k0 pushed a commit to marko-k0/iota.lib.py that referenced this pull request Jul 28, 2018
…set_length

Add offset and length to pycurl
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants