Skip to content

Commit

Permalink
Encode AddTranche.price as little endian
Browse files Browse the repository at this point in the history
  • Loading branch information
NunoAlexandre committed Jan 30, 2023
1 parent c9549f7 commit 1e0e8bb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pallets/connectors/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ impl<
message.append(&mut tranche_id.encode());
message.append(&mut token_name.encode());
message.append(&mut token_symbol.encode());
message.append(&mut price.encode());

let mut encoded_price = price.encode();
encoded_price.reverse();
message.append(&mut encoded_price);

message
}
Expand Down Expand Up @@ -274,7 +277,7 @@ mod tests {

// We encode the encoded bytes as hex to verify it's what we expect
let encoded_hex = hex::encode(encoded_bytes.clone());
let expected_hex = "020000000000bce1a40000000000000000000000000000000105050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050606060606060606060606060606060606060606060606060606060606060606000000e83c80d09f3c2e3b0300000000";
let expected_hex = "020000000000bce1a4000000000000000000000000000000010505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505050505060606060606060606060606060606060606060606060606060606060606060600000000033b2e3c9fd0803ce8000000";
assert_eq!(expected_hex, encoded_hex);

// Now decode the bytes encoded as hex back to bytes and verify it's the same as
Expand Down

0 comments on commit 1e0e8bb

Please sign in to comment.