@@ -1287,4 +1287,33 @@ mod tests {
12871287 let new_bytes = datums. to_bytes ( ) ;
12881288 assert_eq ! ( orig_bytes, new_bytes) ;
12891289 }
1290+
1291+ #[ test]
1292+ pub fn test_cost_model ( ) {
1293+ let arr = vec ! [
1294+ 197209 , 0 , 1 , 1 , 396231 , 621 , 0 , 1 , 150000 , 1000 , 0 , 1 , 150000 , 32 ,
1295+ 2477736 , 29175 , 4 , 29773 , 100 , 29773 , 100 , 29773 , 100 , 29773 , 100 , 29773 ,
1296+ 100 , 29773 , 100 , 100 , 100 , 29773 , 100 , 150000 , 32 , 150000 , 32 , 150000 , 32 ,
1297+ 150000 , 1000 , 0 , 1 , 150000 , 32 , 150000 , 1000 , 0 , 8 , 148000 , 425507 , 118 ,
1298+ 0 , 1 , 1 , 150000 , 1000 , 0 , 8 , 150000 , 112536 , 247 , 1 , 150000 , 10000 , 1 ,
1299+ 136542 , 1326 , 1 , 1000 , 150000 , 1000 , 1 , 150000 , 32 , 150000 , 32 , 150000 ,
1300+ 32 , 1 , 1 , 150000 , 1 , 150000 , 4 , 103599 , 248 , 1 , 103599 , 248 , 1 , 145276 ,
1301+ 1366 , 1 , 179690 , 497 , 1 , 150000 , 32 , 150000 , 32 , 150000 , 32 , 150000 , 32 ,
1302+ 150000 , 32 , 150000 , 32 , 148000 , 425507 , 118 , 0 , 1 , 1 , 61516 , 11218 , 0 , 1 ,
1303+ 150000 , 32 , 148000 , 425507 , 118 , 0 , 1 , 1 , 148000 , 425507 , 118 , 0 , 1 , 1 ,
1304+ 2477736 , 29175 , 4 , 0 , 82363 , 4 , 150000 , 5000 , 0 , 1 , 150000 , 32 , 197209 , 0 ,
1305+ 1 , 1 , 150000 , 32 , 150000 , 32 , 150000 , 32 , 150000 , 32 , 150000 , 32 , 150000 ,
1306+ 32 , 150000 , 32 , 3345831 , 1 , 1 ,
1307+ ] ;
1308+ let cm = arr. iter ( ) . fold ( ( CostModel :: new ( ) , 0 ) , |( mut cm, i) , x| {
1309+ cm. set ( i, & Int :: new_i32 ( x. clone ( ) ) ) ;
1310+ ( cm, i + 1 )
1311+ } ) . 0 ;
1312+ let mut cms = Costmdls :: new ( ) ;
1313+ cms. insert ( & Language :: new_plutus_v1 ( ) , & cm) ;
1314+ assert_eq ! (
1315+ hex:: encode( cms. language_views_encoding( ) ) ,
1316+ "a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"
1317+ ) ;
1318+ }
12901319}
0 commit comments