Skip to content

Commit

Permalink
Redact compiledCode & hash in generated blueprint tests
Browse files Browse the repository at this point in the history
  The point of those tests is to ensure that blueprints are generated
  properly, irrespective of the generated code. It is annoying to
  constantly get those test failing every time we introduce an
  optimization or something that would slightly change the generated
  UPLC.
  • Loading branch information
KtorZ committed Aug 3, 2024
1 parent 2c57575 commit 5610ee0
Show file tree
Hide file tree
Showing 15 changed files with 368 additions and 282 deletions.
588 changes: 335 additions & 253 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ x86_64-unknown-linux-gnu = "ubuntu-22.04"

[workspace.dependencies]
walkdir = "2.3.2"
insta = { version = "1.30.0", features = ["yaml", "json"] }
insta = { version = "1.30.0", features = ["yaml", "json", "redactions"] }
pallas-addresses = "0.22.0"
pallas-codec = { version = "0.22.0", features = ["num-bigint"] }
pallas-crypto = "0.22.0"
Expand Down
8 changes: 3 additions & 5 deletions crates/aiken-lang/src/gen_uplc/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,9 @@ pub fn find_introduced_variables(air_tree: &AirTree) -> Vec<String> {
.cloned()
.chain(snd_name.iter().cloned())
.collect_vec(),
AirTree::PairAccessor { fst, snd, .. } => fst
.iter()
.cloned()
.chain(snd.iter().cloned())
.collect_vec(),
AirTree::PairAccessor { fst, snd, .. } => {
fst.iter().cloned().chain(snd.iter().cloned()).collect_vec()
}
AirTree::PairClause {
fst_name, snd_name, ..
} => fst_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ description: "Code:\n\npub type Foo {\n foo: Int\n}\n\nvalidator {\n fn an
"$ref": "#/definitions/Data"
}
},
"compiledCode": "5833010000323222253330044a22930a99802a491856616c696461746f722072657475726e65642066616c736500136565734ae701",
"hash": "52a21f2b4f282074cb6c5aefef20d18c25f3657ca348c73875810c37",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"Data": {
"title": "Data",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ description: "Code:\n\ntype Either<left, right> {\n Left(left)\n Right(rig
"$ref": "#/definitions/test_module~1Either$ByteArray_test_module~1Interval$Int"
}
},
"compiledCode": "590156010000323232323232323232232253330054a22930a9980324811856616c696461746f722072657475726e65642066616c73650013656323253330053370e90000008992999805000802899299980598068010a4c00c64a66666601c00200c00c00c00c26eb8004c02c004c020dd50010a99980299b87480080044c94ccc0280040144c94ccc02cc0340084c9263253330083370e90000008992999806800804099299980718080010a4c01264a66666602200201201201226eb4004024c038004c02cdd50010a99980419b874800800454ccc030c02cdd50010a4c00e00e60126ea8004018c94cccccc0380044004018018018018c02c004c020dd500100218031baa001533333300a001100100200200200215330024912a72656465656d65723a204569746865723c4279746541727261792c20496e74657276616c3c496e743e3e00165734ae7155ceaab9e5573eae855d12ba41",
"hash": "d9891fd7080a2e6e3a68d330ef987b6950115bbe0700f1dfeab7af2f",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"ByteArray": {
"dataType": "bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ description: "Code:\n\ntype Dict<key, value> {\n inner: List<(ByteArray, valu
"$ref": "#/definitions/test_module~1Dict$test_module~1UUID_Int"
}
},
"compiledCode": "59012c010000323232323232323232232253330054a22930a9980324811856616c696461746f722072657475726e65642066616c736500136563253330043370e900018031baa0011325333009001004132533300a300c002132498c8cc004004008894ccc03000452613233003003300f0023232533300e00100913232533301000100b132533301130130021498030c94cccccc0500040300300304dd68008061808800980880119299999980900080500500500509bae001300f001533333301000100800813758002010010601a00200a64a66666601a00200a00a26eb0004014014c028004c01cdd5000801a99999980500088008010010010010a9980124811972656465656d65723a20446963743c555549442c20496e743e00165734ae7155ceaab9e5573eae855d12ba41",
"hash": "41a2fefe69a528618655adf8d9c426133a166851b2acf234ff889400",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"ByteArray": {
"dataType": "bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ description: "Code:\n\ntype Dict<key, value> {\n inner: List<Pair<ByteArray,
"$ref": "#/definitions/test_module~1Dict$test_module~1UUID_Int"
}
},
"compiledCode": "58fd010000323232323232323232232253330054a22930a9980324811856616c696461746f722072657475726e65642066616c736500136563253330043370e900018031baa0011325333009001004132533300a300c002132498c8cc004004008894ccc03000452613233003003300f002323232533333301200100a00a00a1375a002014601a00464a66666602200201201201201226eb8004c02c004c034004014c94cccccc0340040144dd5800802802802980500098039baa001003533333300a0011001002002002002153300249011972656465656d65723a20446963743c555549442c20496e743e00165734ae7155ceaab9e5573eae855d12ba41",
"hash": "b506dcde933daf4709a5883ce8fdf7c159d147b8e81d860947918ad3",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"ByteArray": {
"dataType": "bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ description: "Code:\n\nvalidator {\n fn mint(redeemer: Data, ctx: Data) {\n
"$ref": "#/definitions/Data"
}
},
"compiledCode": "583301000032322253330034a22930a9980224811856616c696461746f722072657475726e65642066616c736500136565734ae701",
"hash": "9fc33a6ffaa8d1f600c161aa383739d5af37807ed83347cc133521c9",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"Data": {
"title": "Data",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ description: "Code:\n\nvalidator(utxo_ref: Int) {\n fn mint(redeemer: Data, ctx
}
}
],
"compiledCode": "583701000032322322253330054a22930a998032491856616c696461746f722072657475726e65642066616c73650013656375a002ae695ce1",
"hash": "2837caccfd96d636a07e0da584ebbef94069bd7bfa4447096ecd9b80",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"Data": {
"title": "Data",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ description: "Code:\n\npub type Foo {\n foo: Data\n}\n\nvalidator {\n fn nes
"$ref": "#/definitions/Int"
}
},
"compiledCode": "58bc01000032323232323232323232232232253330084a22930a99804a491856616c696461746f722072657475726e65642066616c73650013656533333300d0010040040041375a00200864a66600a66e1d200030073754002264a66601400200a264a666016601a004293003180580098041baa001004533333300b001100100300300300315330034910d72656465656d65723a20496e74001615330024910a646174756d3a20466f6f00165734ae7155ceaab9e5573eae855d12ba41",
"hash": "2f3648f0a3fc92a7a6df9e23c8edf3c81c351e83da214f52f1b66d51",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"Data": {
"title": "Data",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ description: "Code:\n\npub type LinkedList<a> {\n Cons(a, LinkedList<a>)\n Nil
"$ref": "#/definitions/test_module~1LinkedList$Int"
}
},
"compiledCode": "5902dc01000032323232323232323232232323232322322533300c4a22930a99806a491856616c696461746f722072657475726e65642066616c73650013656330035333333011001100100800800800800833232232533300c3008001132533301100100c13253330123014002132498cc014004034034c94cccccc0540044004034034034034c048004c03cdd50010a99980618038008992999808800806099192999809800807099299980a180b00109924ca66602800201e26464a66602c002022264a66602e603200426493191980080080111299980c8008a4c264660060066038004646601ea66666603a002200202a02a02a02a02a603400202464a66666603400202402426eb0004048048c05c004c05c008c94cccccc0600040400400400404dd7000980a80080799299999980b80080780789bac00100f00f3014001301400232533333301500100d00d00d1375a00201a6024002601e6ea800802cc034dd5000980080091119299980618040008992999808800806099192999809800807099299980a180b00109924c66601001000201e01e64a66666602e002200201e01e01e01e6028002602800464a66666602a002264a66602660240022a66601e60146022002294454ccc03cc02cc0440045280070071baa00100d00d00d00d3012001300f37540062a666018600e0022a666020601e6ea800c52600b00b300d3754004a66666601e00a200a00e00e00e00e600200244464a666014600c002264a66601e00201226464a666022002016264a66602460280042649319980400400080600619299999980a80088008060060060061809000980900119299999980980080500500509bad00100a3010001300d37540062a666014600a0022a66601c601a6ea800c526008008300b37540046e1d2002370e90000a99801a4811972656465656d65723a204c696e6b65644c6973743c496e743e001615330024910a646174756d3a20466f6f00165734ae7155ceaab9e5573eae855d12ba41",
"hash": "84b32ffc00b858865c8047f8145074fd841a828bfa1cd48c25e204ec",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"Bool": {
"title": "Bool",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ description: "Code:\n\npub type Expr {\n Val(Int)\n Sum(Expr, Expr)\n Mul(Exp
"$ref": "#/definitions/test_module~1Expr"
}
},
"compiledCode": "590182010000323232323232323232232253330054a22930a9980324811856616c696461746f722072657475726e65642066616c73650013656333230010012223253330073370e90000008992999806000803899299980698078010a4c01064a66666602000201001001026eb4004020c034004c028dd50018a99980399b87480080044c94ccc03000401c4c8c94ccc0380040244c94ccc03cc0440084c8c92633300900900200b33300800800300a00a325333333012001100100a00a00a00a300f001300f0023253333330100011001008008008008300d001300a37540062a66600e66e1d2004001132533300c00100713232533300e001009132533300f301100213232498ccc02402400802cccc02002000c028028c94cccccc0480044004028028028028c03c004c03c008c94cccccc0400044004020020020020c034004c028dd500180318041baa002533333300a0011001002002002002002153300249010e72656465656d65723a204578707200165734ae7155ceaab9e5573eae855d12ba41",
"hash": "5e5d31d96828f3f0b12ac296adc263de4ac0964cae3cac0164f525e1",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"Int": {
"dataType": "integer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ description: "Code:\n\n/// On-chain state\ntype State {\n /// The contestatio
"$ref": "#/definitions/test_module~1Input"
}
},
"compiledCode": "5901c60100003232323232323232323223232232253330094a22930a998052491856616c696461746f722072657475726e65642066616c736500136563232533300930050011533300d300c37540042930038a99980499b874800800454ccc034c030dd50010a4c00e2a66601266e1d20040011533300d300c375400429300380398051baa001533333300e0011001005005005005325333006300230083754002264a66601600200c26464a66601a00201026464a66601e002014264a6660206024004264649319198008008029129998098008a4c26466006006602c00464a66666602e00201e01e01e01e26eb8004c0500054ccc030c020c038dd500289929998088008060992999809180a0010a4c01a64a66666602a00201a01a01a26eb4004034c048004c03cdd500280580599299999980980080580580580589bae0013010001301000232533333301100100900913758002012012601c002601c00464a66666601e002200200e00e00e00e601800260126ea80040154cccccc0300084008010010010010dc3a40002a6600692010f72656465656d65723a20496e707574001615330024910c646174756d3a20537461746500165734ae7155ceaab9e5573eae855d12ba41",
"hash": "02a625742f53a006e38b3c9abbcd3c77002815705ad1f6a5a6b02813",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"ByteArray": {
"dataType": "bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ description: "Code:\n\nvalidator {\n fn tuples(datum: (Int, ByteArray), redeeme
"$ref": "#/definitions/Tuple$Int_Int_Int"
}
},
"compiledCode": "590158010000323232323232323223232232322533300a4a22930a99805a491856616c696461746f722072657475726e65642066616c73650013656533300a00100613232533300c00100813232533300e00100a132533300f3011002149802cc94cccccc04800402c02c02c4dd68008059807800980780119299999980800080480480489bad001009300d001300d00232533333300e0010070070071375a00200e6016002a66666601800200a00a26eb00040140154ccc01c0040104c8c94ccc0240040184c94ccc028c03000852600732533333300d0010070070070071375c0026014002601400464a66666601600200a00a00a26eb4004014c0200054cccccc02400400c00c4dd60008018018a99801a4811972656465656d65723a2028496e742c20496e742c20496e74290016153300249117646174756d3a2028496e742c204279746541727261792900165734ae7155cfaba15744ae91",
"hash": "a537eed4619425e300f33b8a9734144c9e8d4ab2177e563e9a2881c3",
"compiledCode": "<redacted>",
"hash": "<redacted>",
"definitions": {
"ByteArray": {
"dataType": "bytes"
Expand Down
8 changes: 7 additions & 1 deletion crates/aiken-project/src/blueprint/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,13 @@ mod tests {
description => concat!("Code:\n\n", indoc::indoc! { $code }),
omit_expression => true
}, {
insta::assert_json_snapshot!(validator);
insta::assert_json_snapshot!(
validator,
{
".compiledCode" => "<redacted>",
".hash" => "<redacted>"
}
);
}),
};
};
Expand Down

0 comments on commit 5610ee0

Please sign in to comment.