From 7073fd29b3e1973c1d95ccb97e528c8109fbe24d Mon Sep 17 00:00:00 2001 From: rvcas Date: Tue, 7 Nov 2023 15:56:05 -0500 Subject: [PATCH] test(bls): literal parsing tests --- .../aiken-lang/src/parser/expr/bytearray.rs | 10 +++ .../src/parser/expr/snapshots/g1_element.snap | 44 ++++++++++ .../src/parser/expr/snapshots/g2_element.snap | 86 +++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 crates/aiken-lang/src/parser/expr/snapshots/g1_element.snap create mode 100644 crates/aiken-lang/src/parser/expr/snapshots/g2_element.snap diff --git a/crates/aiken-lang/src/parser/expr/bytearray.rs b/crates/aiken-lang/src/parser/expr/bytearray.rs index a750f441..376f3eeb 100644 --- a/crates/aiken-lang/src/parser/expr/bytearray.rs +++ b/crates/aiken-lang/src/parser/expr/bytearray.rs @@ -63,4 +63,14 @@ mod tests { fn bytearray_utf8_escaped() { assert_expr!("\"\\\"aiken\\\"\""); } + + #[test] + fn g1_element() { + assert_expr!("#\"950dfd33da2682260c76038dfb8bad6e84ae9d599a3c151815945ac1e6ef6b1027cd917f3907479d20d636ce437a41f5\""); + } + + #[test] + fn g2_element() { + assert_expr!("#\"b0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1\""); + } } diff --git a/crates/aiken-lang/src/parser/expr/snapshots/g1_element.snap b/crates/aiken-lang/src/parser/expr/snapshots/g1_element.snap new file mode 100644 index 00000000..894edafd --- /dev/null +++ b/crates/aiken-lang/src/parser/expr/snapshots/g1_element.snap @@ -0,0 +1,44 @@ +--- +source: crates/aiken-lang/src/parser/expr/bytearray.rs +description: "Code:\n\n#\"950dfd33da2682260c76038dfb8bad6e84ae9d599a3c151815945ac1e6ef6b1027cd917f3907479d20d636ce437a41f5\"" +--- +CurvePoint { + location: 0..114, + point: Bls12_381( + G1( + blst_p1 { + x: blst_fp { + l: [ + 6044239372598254900, + 11111890802926526657, + 302563157772145122, + 17359147598889707489, + 6255098506247414666, + 1773881592225990778, + ], + }, + y: blst_fp { + l: [ + 9961536754182800925, + 16512912018612749997, + 10822258563185590636, + 17742512098199848220, + 16542676355910829810, + 1246663995533626329, + ], + }, + z: blst_fp { + l: [ + 8505329371266088957, + 17002214543764226050, + 6865905132761471162, + 8632934651105793861, + 6631298214892334189, + 1582556514881692819, + ], + }, + }, + ), + ), + preferred_format: HexadecimalString, +} diff --git a/crates/aiken-lang/src/parser/expr/snapshots/g2_element.snap b/crates/aiken-lang/src/parser/expr/snapshots/g2_element.snap new file mode 100644 index 00000000..3fa096bc --- /dev/null +++ b/crates/aiken-lang/src/parser/expr/snapshots/g2_element.snap @@ -0,0 +1,86 @@ +--- +source: crates/aiken-lang/src/parser/expr/bytearray.rs +description: "Code:\n\n#\"b0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1\"" +--- +CurvePoint { + location: 0..210, + point: Bls12_381( + G2( + blst_p2 { + x: blst_fp2 { + fp: [ + blst_fp { + l: [ + 17730081354175209597, + 14393386882433024580, + 15392237588654399813, + 13132804324748058634, + 437180824693959563, + 1209861931331675905, + ], + }, + blst_fp { + l: [ + 16640134302799489459, + 13200372101402265278, + 3491868243815184488, + 15749231165976205625, + 10700844509881097270, + 978652262052845623, + ], + }, + ], + }, + y: blst_fp2 { + fp: [ + blst_fp { + l: [ + 15138882304466955413, + 4159460337006967255, + 16059739792181277381, + 4673287545394659101, + 6265740687822174786, + 1492317236631555918, + ], + }, + blst_fp { + l: [ + 7482650483077279660, + 1528034342759119680, + 1732030343867801117, + 8394128533480400141, + 6497663211870147931, + 683724859415636652, + ], + }, + ], + }, + z: blst_fp2 { + fp: [ + blst_fp { + l: [ + 8505329371266088957, + 17002214543764226050, + 6865905132761471162, + 8632934651105793861, + 6631298214892334189, + 1582556514881692819, + ], + }, + blst_fp { + l: [ + 0, + 0, + 0, + 0, + 0, + 0, + ], + }, + ], + }, + }, + ), + ), + preferred_format: HexadecimalString, +}