phink 0.1.5

🐙 Phink, a ink! smart-contract property-based and coverage-guided fuzzer
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
use crate::{
    contract::selectors::selector::Selector,
    ResultOf,
};
use anyhow::{
    bail,
    Context,
};
use serde::Deserialize;
use serde_json::Value;
use std::{
    fs,
    path::PathBuf,
    str::FromStr,
};

#[derive(Default, Clone)]
pub struct PayloadCrafter;

/// This prefix defines the way a property start with
///
/// # Example
// ```rust
// #[ink(message)]
// pub fn phink_assert_abc_dot_com_cant_be_registered(&self) -> bool {}
/// ```
pub const DEFAULT_PHINK_PREFIX: &str = "phink_";
#[derive(Deserialize, Debug, Clone)]
struct Spec {
    constructors: Vec<SelectorEntry>,
    messages: Vec<SelectorEntry>,
}

impl Spec {
    pub fn parse(&self) -> ResultOf<Vec<Selector>> {
        if self.constructors.is_empty() || self.messages.is_empty() {
            bail!("Empty constructor or messages vec")
        };

        self.constructors
            .iter()
            .chain(self.messages.iter())
            .map(|entry| Selector::try_from(entry.selector.as_str()))
            .collect::<Result<_, _>>()
            .map_err(|e| anyhow::anyhow!("Couldn't push the selector while parsing: {e}"))
    }
}

#[derive(Deserialize, Clone, Debug)]
struct SelectorEntry {
    selector: String,
}
impl PayloadCrafter {
    pub fn extract_all(contract_path: PathBuf) -> ResultOf<Vec<Selector>> {
        let mut all_selectors = Vec::new();

        let target_ink_path = contract_path.join("target/ink");
        let entries = fs::read_dir(&target_ink_path)
            .with_context(|| format!("Failed to read directory {target_ink_path:?}"))?;

        for entry in entries {
            let path = entry
                .with_context(|| "Failed to read directory entry")?
                .path();

            if path.extension().map_or(false, |ext| ext == "json")
                && !path.file_name().unwrap().to_str().unwrap().starts_with(".")
            {
                let contents = fs::read_to_string(&path)
                    .with_context(|| format!("Failed to read file {path:?}"))?;

                let v: Value = serde_json::from_str(&contents)
                    .with_context(|| format!("Failed to parse JSON from file {path:?}"))?;

                let spec: Spec = serde_json::from_value(v["spec"].clone())
                    .with_context(|| format!("Failed to deserialize spec from file {path:?}"))?;

                let selectors = spec.parse().context("Couldn't parse all the selectors")?;
                all_selectors.extend(selectors);
                break; // Since we only want to process the first JSON file found, break the loop
            }
        }

        Ok(all_selectors)
    }

    pub fn extract_payables(json_data: &str) -> Option<Vec<Selector>> {
        let data: Value = serde_json::from_str(json_data).expect("JSON was not well-formatted");

        Some(
            data["spec"]["messages"]
                .as_array()
                .unwrap_or(&Vec::new())
                .iter()
                .filter_map(|message| {
                    if message["payable"].as_bool() == Some(true) {
                        message["selector"]
                            .as_str()
                            .map(|s| Selector::try_from(s).unwrap())
                    } else {
                        None
                    }
                })
                .collect(),
        )
    }
    /// Extract every selector associated to the invariants defined in the ink!
    /// smart-contract See the documentation of `DEFAULT_PHINK_PREFIX` to know
    /// more about how to create a properties
    ///
    /// # Arguments
    /// * `json_data`: The JSON specs of the smart-contract
    pub fn extract_invariants(json_data: &str) -> Option<Vec<Selector>> {
        let data: Value = serde_json::from_str(json_data).expect("JSON was not well-formatted");

        Some(
            data["spec"]["messages"]
                .as_array()
                .unwrap_or(&Vec::new())
                .iter()
                .filter_map(|message| {
                    message["label"]
                        .as_str()
                        .filter(|label| label.starts_with(DEFAULT_PHINK_PREFIX))
                        .and_then(|_| message["selector"].as_str())
                        .map(|e| Selector::try_from(e).unwrap())
                })
                .collect(),
        )
    }

    /// Return the smart-contract constructor based on its spec. If there are
    /// multiple constructors, returns the one that preferably doesn't have
    /// args. If no suitable constructor is found or there is an error in
    /// processing, this function returns `Err`.
    pub fn extract_constructor(json_data: &str) -> ResultOf<Selector> {
        let parsed_json: Value = serde_json::from_str(json_data)?;

        let constructors = parsed_json["spec"]["constructors"].as_array().unwrap();

        if constructors.len() == 1 {
            return Selector::from_str(constructors[0]["selector"].as_str().unwrap());
        }

        // Otherwise, look for a constructor without arguments.
        for constructor in constructors {
            if constructor["args"].as_array().map_or(false, Vec::is_empty) {
                return Selector::from_str(constructor["selector"].as_str().unwrap())
            }
        }
        bail!("No selector found")
    }
}

#[cfg(test)]
mod test {
    use super::*;
    use crate::{
        cli::{
            config::Configuration,
            ziggy::ZiggyConfig,
        },
        contract::payload::PayloadCrafter,
        fuzzer::{
            fuzz::Fuzzer,
            parser::{
                try_parse_input,
                Origin,
            },
        },
        instrumenter::path::InstrumentedPath,
        EmptyResult,
    };
    use contract_transcode::ContractMessageTranscoder;

    use sp_core::hexdisplay::AsBytesRef;
    use std::{
        fs,
        path::{
            Path,
            PathBuf,
        },
    };
    use tempfile::TempDir;

    #[test]
    fn test_parse_selectors() {
        let spec = Spec {
            constructors: vec![SelectorEntry {
                selector: "0x12345678".to_string(),
            }],
            messages: vec![
                SelectorEntry {
                    selector: "0xabcdef01".to_string(),
                },
                SelectorEntry {
                    selector: "0x23456789".to_string(),
                },
            ],
        };

        let selectors = spec.parse().unwrap();

        assert_eq!(selectors.len(), 3);
        assert_eq!(selectors[0], Selector::from([0x12, 0x34, 0x56, 0x78]));
        assert_eq!(selectors[1], Selector::from([0xab, 0xcd, 0xef, 0x01]));
        assert_eq!(selectors[2], Selector::from([0x23, 0x45, 0x67, 0x89]));
    }

    #[test]
    fn test_extract_invariants() {
        let json_data = r#"
        {
            "spec": {
                "messages": [
                    {
                        "label": "phink_test_invariant",
                        "selector": "0x12345678"
                    },
                    {
                        "label": "normal_function",
                        "selector": "0xabcdef01"
                    },
                    {
                        "label": "phink_another_invariant",
                        "selector": "0x23456789"
                    }
                ]
            }
        }
        "#;

        let invariants = PayloadCrafter::extract_invariants(json_data).unwrap();

        assert_eq!(invariants.len(), 2);
        assert_eq!(invariants[0], Selector::from([0x12, 0x34, 0x56, 0x78]));
        assert_eq!(invariants[1], Selector::from([0x23, 0x45, 0x67, 0x89]));
    }

    #[test]
    fn test_extract_payable() {
        let specs = fs::read_to_string("sample/transfer/target/ink/transfer.json").unwrap();

        let invariants = PayloadCrafter::extract_payables(specs.as_str()).unwrap();

        assert_eq!(invariants.len(), 1);
        assert_eq!(invariants[0], Selector::from([0x47, 0x18, 0x7f, 0x3e])); // 0x47 18 7f 3e
    }

    #[test]
    fn test_get_constructor() {
        let json_data = r#"
        {
            "spec": {
                "constructors": [
                    {
                        "label": "new",
                        "selector": "0x12345678",
                        "args": []
                    },
                    {
                        "label": "new_with_value",
                        "selector": "0xabcdef01",
                        "args": [
                            {
                                "label": "value",
                                "type": {
                                    "displayName": ["u128"],
                                    "type": 0
                                }
                            }
                        ]
                    }
                ]
            }
        }
        "#;

        let constructor = PayloadCrafter::extract_constructor(json_data).unwrap();
        assert_eq!(constructor, [0x12, 0x34, 0x56, 0x78].into());
    }

    #[test]
    fn test_extract_all() {
        let temp_dir = TempDir::new().unwrap();
        let file_path = temp_dir.path().join("target/ink/");
        fs::create_dir_all(&file_path).unwrap();
        let json_content = r#"
        {
            "spec": {
                "constructors": [
                    {
                        "selector": "0x12345678"
                    }
                ],
                "messages": [
                    {
                        "selector": "0xabcdef01"
                    }
                ]
            }
        }
        "#;
        fs::write(file_path.join("contract.json"), json_content).unwrap();

        let selectors = PayloadCrafter::extract_all(temp_dir.path().to_path_buf()).unwrap();

        assert_eq!(selectors.len(), 2);
        assert_eq!(selectors[0], Selector::from([0x12, 0x34, 0x56, 0x78]));
        assert_eq!(selectors[1], Selector::from([0xab, 0xcd, 0xef, 0x01]));
    }
    #[test]
    fn fetch_good_invariants() {
        let specs = fs::read_to_string("sample/dns/target/ink/dns.json").unwrap();
        let extracted: String = PayloadCrafter::extract_invariants(&specs)
            .unwrap()
            .iter()
            .map(|x| hex::encode(x) + " ")
            .collect();

        // DNS invariants
        assert_eq!(extracted, "2093daa4 ");
    }
    #[test]
    fn fetch_dummy_selectors() {
        let extracted: String = PayloadCrafter::extract_all(PathBuf::from("sample/dummy/"))
            .unwrap()
            .iter()
            .map(|x| x.to_string() + " ")
            .collect();

        // Dummy selectors
        assert!(
            extracted.contains("fa80c2f6"),
            "If this panics, check that the contracts were compiled with the phink features!\n\
        Go to samples/* and run `cargo contract build --features phink`"
        );
    }
    #[test]
    fn fetch_correct_selectors() {
        let extracted: String = PayloadCrafter::extract_all(PathBuf::from("sample/dns/"))
            .unwrap()
            .iter()
            .map(|x| x.to_string() + " ")
            .collect();

        // DNS selectors
        assert_eq!(
            extracted,
            "9bae9d5e 229b553f b8a4d3d9 84a15da1 d259f7ba 07fcd0b1 2093daa4 "
        );
    }

    #[test]
    fn fetch_correct_dns_constructor() {
        let dns_spec = fs::read_to_string("sample/dns/target/ink/dns.json").unwrap();
        let ctor: Selector = PayloadCrafter::extract_constructor(&dns_spec).unwrap();

        // DNS default selectors
        assert_eq!(hex::encode(ctor), "9bae9d5e");
    }

    #[test]
    fn encode_works_good() {
        let metadata_path = Path::new("sample/dns/target/ink/dns.json");
        let transcoder = ContractMessageTranscoder::load(metadata_path).unwrap();
        let constructor = "set_address";
        let args = [
            // name: Hash, new_address: AccountId
            "re",
            "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
        ];
        let data = transcoder.encode(constructor, args).unwrap();
        let hex = hex::encode(data);
        assert_eq!(
            hex,
            "b8a4d3d9d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"
        );
    }
    #[test]
    fn dummy_encode() {
        let metadata_path = Path::new("sample/dummy/target/ink/dummy.json");
        let transcoder = ContractMessageTranscoder::load(metadata_path).unwrap();
        let constructor = "crash_with_invariant";
        let data = transcoder.encode(constructor, ["\"\""]).unwrap();
        let hex = hex::encode(data);
        assert_eq!(hex, "fa80c2f600");
        // println!("{hex:?}");
    }

    #[test]
    fn parse_one_message_dummy() -> EmptyResult {
        let encoded_bytes = hex::decode("0000000001fa80c2f600")?;

        let configuration = Configuration {
            max_messages_per_exec: Some(4), // because we have two messages below
            instrumented_contract_path: Some(InstrumentedPath::from("sample/dummy")),
            // below is a hack, `sample/dns` isn't the instrumented, but for the test we don't care
            ..Default::default()
        };

        let ziggy_config: ZiggyConfig =
            ZiggyConfig::new_with_contract(configuration, PathBuf::from("sample/dummy")).unwrap();

        let manager = Fuzzer::new(Ok(ziggy_config))?
            .init_fuzzer()
            .context("Couldn't grap the transcoder and the invariant manager")?;

        let input = try_parse_input(encoded_bytes.as_bytes_ref(), manager.to_owned()).unwrap();

        let msg = input.messages;
        // println!("{:?}", msg);

        assert_eq!(msg.len(), 1, "No messages decoded");
        assert_eq!(
            msg.first().unwrap().origin,
            Origin::default(),
            "Origin is supposed to be the default one"
        );

        for i in 0..msg.len() {
            let hex = manager
                .transcoder()
                .lock()
                .unwrap()
                .decode_contract_message(&mut &*msg.get(i).unwrap().payload);
            assert!(hex.is_ok(), "Decoding wasn't Ok")
        }
        Ok(())
    }

    #[test]
    fn test_custom_origin() -> EmptyResult {
        let encoded_bytes = hex::decode("00000000fffa80c2f600")?;

        let configuration = Configuration {
            max_messages_per_exec: Some(4), // because we have two messages below
            fuzz_origin: true,
            instrumented_contract_path: Some(InstrumentedPath::from("sample/dummy")),
            // below is a hack, `sample/dns` isn't the instrumented, but for the test we don't care
            ..Default::default()
        };

        let ziggy_config: ZiggyConfig =
            ZiggyConfig::new_with_contract(configuration, PathBuf::from("sample/dummy"))?;

        let manager = Fuzzer::new(Ok(ziggy_config))?
            .init_fuzzer()
            .context("Couldn't grap the `transcoder` and the invariant manager")?;

        let input = try_parse_input(encoded_bytes.as_bytes_ref(), manager.to_owned()).unwrap();

        let msg = input.messages;
        // println!("{:?}", msg);

        assert_eq!(msg.len(), 1, "No messages decoded");
        assert_eq!(
            msg.first().unwrap().origin,
            Origin::from(0xff), // origin was ff
            "Origin is supposed to be the default one"
        );

        for i in 0..msg.len() {
            let hex = manager
                .transcoder()
                .lock()
                .unwrap()
                .decode_contract_message(&mut &*msg.get(i).unwrap().payload);
            assert!(hex.is_ok(), "Decoding wasn't Ok");

            // println!("{:?}", hex.unwrap());
        }
        Ok(())
    }

    #[test]
    fn test_good_money_transfered() -> EmptyResult {
        let binding = hex::decode(
            "ffffffff\
        ff\
        fa80c2f600",
        )?;
        let encoded_bytes: &[u8] = binding.as_slice();

        let configuration = Configuration {
            max_messages_per_exec: Some(4), // because we have two messages below
            fuzz_origin: true,
            instrumented_contract_path: Some(InstrumentedPath::from("sample/dummy")),
            verbose: false,
            // below is a hack, `sample/dns` isn't the instrumented, but for the test we don't care
            ..Default::default()
        };

        let ziggy_config: ZiggyConfig =
            ZiggyConfig::new_with_contract(configuration, PathBuf::from("sample/dummy"))?;

        let manager = Fuzzer::new(Ok(ziggy_config))?
            .init_fuzzer()
            .context("Couldn't grap the transcoder and the invariant manager")?;

        let input = try_parse_input(encoded_bytes, manager.to_owned()).unwrap();

        let msg = input.messages;
        // println!("{:?}", msg);

        assert_eq!(msg.len(), 1, "No messages decoded");
        assert_eq!(
            msg.first().unwrap().origin,
            Origin::from(0xff), // origin was ff
            "Origin is supposed to be the default one"
        );

        assert_eq!(
            msg.first().unwrap().value_token,
            0,
            "Value transfered is supposed to be zero because even if we have FFFF, the message isn't transferable"
        );

        for i in 0..msg.len() {
            let hex = manager
                .transcoder()
                .lock()
                .unwrap()
                .decode_contract_message(&mut &*msg.get(i).unwrap().payload);
            assert!(hex.is_ok(), "Decoding wasn't Ok")
        }
        Ok(())
    }

    #[test]
    fn test_good_money_to_transferable_msg_transfered() -> EmptyResult {
        let binding = hex::decode(
            "ffffffff\
        ff\
        47187f3e",
        )?;
        let encoded_bytes: &[u8] = binding.as_slice();

        let configuration = Configuration {
            max_messages_per_exec: Some(4), // because we have two messages below
            fuzz_origin: true,
            instrumented_contract_path: Some(InstrumentedPath::from("sample/transfer")),
            verbose: false,
            // below is a hack, `sample/dns` isn't the instrumented, but for the test we don't care
            ..Default::default()
        };

        let ziggy_config: ZiggyConfig =
            ZiggyConfig::new_with_contract(configuration, PathBuf::from("sample/transfer"))?;

        let manager = Fuzzer::new(Ok(ziggy_config))?
            .init_fuzzer()
            .context("Couldn't grap the transcoder and the invariant manager")?;

        let input = try_parse_input(encoded_bytes, manager.to_owned()).unwrap();

        let msg = input.messages;
        // println!("{:?}", msg);

        assert_eq!(msg.len(), 1, "No messages decoded");
        assert_eq!(
            msg.first().unwrap().origin,
            Origin::from(0xff), // origin was ff
            "Origin is supposed to be the default one"
        );

        assert_eq!(
            msg.first().unwrap().value_token,
            4294967295,
            "Value transfered is supposed to be 4294967295"
        );

        for i in 0..msg.len() {
            let hex = manager
                .transcoder()
                .lock()
                .unwrap()
                .decode_contract_message(&mut &*msg.get(i).unwrap().payload);
            assert!(hex.is_ok(), "Decoding wasn't Ok")
        }
        Ok(())
    }
    #[test]
    fn parse_one_input_with_two_messages_dns() -> EmptyResult {
        let encoded_bytes = hex::decode(
            "0000000001229b553f9400000000000000000027272727272727272700002727272727272727272727\
            2a2a2a2a2a2a2a2a\
            0000000001229b553f9400000000000000000027272727272727272700002727272727272727272727",
        )?;

        let configuration = Configuration {
            max_messages_per_exec: Some(4), // because we have two messages below
            instrumented_contract_path: Some(InstrumentedPath::from("sample/dns")),
            // below is a hack, `sample/dns` isn't the instrumented, but for the test we don't care
            ..Default::default()
        };

        let ziggy_config: ZiggyConfig =
            ZiggyConfig::new_with_contract(configuration, PathBuf::from("sample/dns"))?;

        let manager = Fuzzer::new(Ok(ziggy_config))?
            .init_fuzzer()
            .context("Couldn't grap the transcoder and the invariant manager")?;

        let input = try_parse_input(encoded_bytes.as_bytes_ref(), manager.to_owned()).unwrap();

        let msg = input.messages;
        // println!("{:?}", msg);

        assert_eq!(msg.len(), 2, "No messages decoded");
        assert_eq!(
            msg.first().unwrap().origin,
            Origin::default(),
            "Origin is supposed to be the default one"
        );

        for i in 0..msg.len() {
            let hex = manager
                .transcoder()
                .lock()
                .unwrap()
                .decode_contract_message(&mut &*msg.get(i).unwrap().payload);
            assert!(hex.is_ok(), "Decoding wasn't Ok")
        }
        Ok(())
    }

    #[test]
    fn assert_reached_too_many_message() -> EmptyResult {
        let encoded_bytes = hex::decode(
            "0000000001229b553f9400000000000000000027272727272727272700002727272727272727272727\
            2a2a2a2a2a2a2a2a\
            0000000001229b553f9400000000000000000027272727272727272700002727272727272727272727\
            2a2a2a2a2a2a2a2a\
            0000000001229b553f9400000000000000000027272727272727272700002727272727272727272727\
            2a2a2a2a2a2a2a2a\
            0000000001229b553f9400000000000000000027272727272727272700002727272727272727272727",
        )?;

        let configuration = Configuration {
            max_messages_per_exec: Some(2), // two messages allow max
            instrumented_contract_path: Some(InstrumentedPath::from("sample/dns")),
            // below is a hack, `sample/dns` isn't the instrumented, but for the test we don't care
            ..Default::default()
        };

        let ziggy_config: ZiggyConfig =
            ZiggyConfig::new_with_contract(configuration, PathBuf::from("sample/dns"))?;

        let manager = Fuzzer::new(Ok(ziggy_config))?
            .init_fuzzer()
            .context("Couldn't grap the transcoder and the invariant manager")?;

        let input = try_parse_input(encoded_bytes.as_bytes_ref(), manager.to_owned()).unwrap();

        let msg = input.messages;
        // println!("{:?}", msg);

        assert_eq!(msg.len(), 2, "Tree parsed but  we put only two max");

        for i in 0..msg.len() {
            let hex = manager
                .transcoder()
                .lock()
                .unwrap()
                .decode_contract_message(&mut &*msg.get(i).unwrap().payload);
            assert!(hex.is_ok(), "Decoding wasn't Ok")
        }
        Ok(())
    }

    #[test]
    fn decode_works_good() {
        let metadata_path = Path::new("sample/dns/target/ink/dns.json");
        let transcoder = ContractMessageTranscoder::load(metadata_path).unwrap();

        let encoded_bytes =
            hex::decode("229b553f9400000000000000000027272727272727272700002727272727272727272727")
                .unwrap();
        let hex = transcoder.decode_contract_message(&mut &encoded_bytes[..]);
        assert_eq!(
            hex.unwrap().to_string(),
            "register { name: 0x9400000000000000000027272727272727272700002727272727272727272727 }"
        );
    }
}