Skip to content

Commit

Permalink
bug: incorrect deserialization of messages
Browse files Browse the repository at this point in the history
  • Loading branch information
prestwich committed Jun 15, 2021
1 parent a7d17dc commit 7013122
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
6 changes: 3 additions & 3 deletions rust/optics-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ impl Decode for OpticsMessage {
let mut sender = H256::zero();
reader.read_exact(sender.as_mut())?;

let mut sequence = [0u8; 4];
reader.read_exact(&mut sequence)?;

let mut destination = [0u8; 4];
reader.read_exact(&mut destination)?;

let mut recipient = H256::zero();
reader.read_exact(recipient.as_mut())?;

let mut sequence = [0u8; 4];
reader.read_exact(&mut sequence)?;

let mut body = vec![];
reader.read_to_end(&mut body)?;

Expand Down
30 changes: 29 additions & 1 deletion vectors/destinationSequenceTestCases.json
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
{"testCases":[{"destination":1,"expectedDestinationAndSequence":4294967298,"sequence":2},{"destination":2,"expectedDestinationAndSequence":8589934595,"sequence":3},{"destination":3,"expectedDestinationAndSequence":12884901892,"sequence":4},{"destination":4,"expectedDestinationAndSequence":17179869189,"sequence":5},{"destination":5,"expectedDestinationAndSequence":21474836486,"sequence":6}]}
{
"testCases": [
{
"destination": 1,
"expectedDestinationAndSequence": 4294967298,
"sequence": 2
},
{
"destination": 2,
"expectedDestinationAndSequence": 8589934595,
"sequence": 3
},
{
"destination": 3,
"expectedDestinationAndSequence": 12884901892,
"sequence": 4
},
{
"destination": 4,
"expectedDestinationAndSequence": 17179869189,
"sequence": 5
},
{
"destination": 5,
"expectedDestinationAndSequence": 21474836486,
"sequence": 6
}
]
}
17 changes: 16 additions & 1 deletion vectors/homeDomainHashTestCases.json
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
{"testCases":[{"expectedDomainHash":"0xfa923b9e3942a539792474b49136600ed6690d0e51c6993e9238819047dfea63","homeDomain":1},{"expectedDomainHash":"0x8caa11ba0b38c460170899d835c99eb38b9319603fe5d391c469da2657e01039","homeDomain":2},{"expectedDomainHash":"0xa2718888038cf3886089211e47a6f2fb003fc887a4f748fd6278156f23f9ecbf","homeDomain":3}]}
{
"testCases": [
{
"expectedDomainHash": "0xfa923b9e3942a539792474b49136600ed6690d0e51c6993e9238819047dfea63",
"homeDomain": 1
},
{
"expectedDomainHash": "0x8caa11ba0b38c460170899d835c99eb38b9319603fe5d391c469da2657e01039",
"homeDomain": 2
},
{
"expectedDomainHash": "0xa2718888038cf3886089211e47a6f2fb003fc887a4f748fd6278156f23f9ecbf",
"homeDomain": 3
}
]
}

0 comments on commit 7013122

Please sign in to comment.