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

Refactor Data and Action Type #272

Conversation

manoranjith
Copy link
Contributor

@manoranjith manoranjith commented Nov 30, 2021

Change Data and Action type from Encoder to binary.(Un)marshaler.

Relates to #233 (Step 1.2) and closes #257.

- Previously, the logic for decoding OptAppAndData was duplicated in
  both the packages. This change removes the duplication.

Signed-off-by: Manoranjith <[email protected]>
- Because, this can be used by other types that implement the binary
  (un)marshaler interface.

Signed-off-by: Manoranjith <[email protected]>
apps/payment/app.go Outdated Show resolved Hide resolved
channel/allocation.go Show resolved Hide resolved
channel/allocation.go Show resolved Hide resolved
channel/app.go Outdated Show resolved Hide resolved
channel/app.go Show resolved Hide resolved
pkg/io/equal_binary.go Show resolved Hide resolved
pkg/io/serialize.go Outdated Show resolved Hide resolved
pkg/io/serialize.go Show resolved Hide resolved
pkg/io/serialize.go Show resolved Hide resolved
pkg/io/serialize.go Show resolved Hide resolved
matthiasgeihs
matthiasgeihs previously approved these changes Dec 7, 2021
- Replace the (En|De)code methods on MockOp,NoData types with
  (Un)marshalBinary methods.

- Replace Decode method on MockApp,NoApp with NewData method.

- Replace GenericSerialzer test on MockApp with GenericMarshaler test.

Signed-off-by: Manoranjith <[email protected]>
- Update pkg/io serializer to encode/decode only the length and skip the
  data for marshaler/unmarshaler type, when the length is zero.

- It is necessary as the GenericSerializer tests for State, Transaction
  etc., were ocassionally failing due to error in Encoding NoApp,NoData.

- Test failed because, in GenericSerializer tests, we use a synchronous
  read,write pipe for testing. In case of zero length byte array, since
  nothing needs to be written to or read from the pipe, the decoder
  occasionally finished reading and closed the pipe before encoder had
  completed writing. And, this caused the encoder's write to fail.

Signed-off-by: Manoranjith <[email protected]>
@matthiasgeihs matthiasgeihs merged commit ee1399a into hyperledger-labs:main Dec 7, 2021
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.

Refactor encoder/decoder interfaces for abstract types in the core packages of go-perun
2 participants