test(bls): constant parsing tests

This commit is contained in:
rvcas 2023-11-07 16:02:20 -05:00 committed by Lucas
parent 7073fd29b3
commit c910e0054e
3 changed files with 175 additions and 0 deletions

View File

@ -84,3 +84,28 @@ pub fn value() -> impl Parser<Token, ast::Constant, Error = ParseError> {
constant_bytearray_parser, constant_bytearray_parser,
)) ))
} }
#[cfg(test)]
mod tests {
use crate::assert_definition;
#[test]
fn g1_element_constant() {
assert_definition!(
r#"
pub const point =
#<Bls12_381, G1>"950dfd33da2682260c76038dfb8bad6e84ae9d599a3c151815945ac1e6ef6b1027cd917f3907479d20d636ce437a41f5"
"#
);
}
#[test]
fn g2_element_constant() {
assert_definition!(
r#"
pub const point =
#<Bls12_381, G2>"b0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1"
"#
);
}
}

View File

@ -0,0 +1,54 @@
---
source: crates/aiken-lang/src/parser/definition/constant.rs
description: "Code:\n\npub const point =\n #<Bls12_381, G1>\"950dfd33da2682260c76038dfb8bad6e84ae9d599a3c151815945ac1e6ef6b1027cd917f3907479d20d636ce437a41f5\"\n"
---
ModuleConstant(
ModuleConstant {
doc: None,
location: 0..134,
public: true,
name: "point",
annotation: None,
value: CurvePoint {
location: 20..134,
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,
},
tipo: (),
},
)

View File

@ -0,0 +1,96 @@
---
source: crates/aiken-lang/src/parser/definition/constant.rs
description: "Code:\n\npub const point =\n #<Bls12_381, G2>\"b0629fa1158c2d23a10413fe91d381a84d25e31d041cd0377d25828498fd02011b35893938ced97535395e4815201e67108bcd4665e0db25d602d76fa791fab706c54abf5e1a9e44b4ac1e6badf3d2ac0328f5e30be341677c8bac5dda7682f1\"\n"
---
ModuleConstant(
ModuleConstant {
doc: None,
location: 0..230,
public: true,
name: "point",
annotation: None,
value: CurvePoint {
location: 20..230,
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,
},
tipo: (),
},
)