-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsonrpc): use padded-base64 for payload encoding
- Loading branch information
Lorenzo Delgado
authored
Feb 23, 2023
1 parent
b6a0117
commit 8258415
Showing
9 changed files
with
77 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
{.used.} | ||
|
||
import | ||
stew/[results, byteutils], | ||
testutils/unittests | ||
import | ||
../../waku/common/base64 | ||
|
||
|
||
suite "Waku Common - stew base64 wrapper": | ||
|
||
test "encode into base64 (with padding)": | ||
## Given | ||
# From RFC 4648 test vectors: https://www.rfc-editor.org/rfc/rfc4648#page-12 | ||
let data = "fooba" | ||
|
||
## When | ||
let encoded = base64.encode(data) | ||
|
||
## Then | ||
check: | ||
encoded == Base64String("Zm9vYmE=") | ||
|
||
|
||
test "decode from base64 (with padding)": | ||
## Given | ||
# From RFC 4648 test vectors: https://www.rfc-editor.org/rfc/rfc4648#page-12 | ||
let data = Base64String("Zm9vYg==") | ||
|
||
## When | ||
let decodedRes = base64.decode(data) | ||
|
||
## Then | ||
check: | ||
decodedRes.isOk() | ||
|
||
let decoded = decodedRes.tryGet() | ||
check: | ||
decoded == toBytes("foob") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters