Skip to content

Commit

Permalink
tmp: add case to checkout cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
liyukun committed Apr 26, 2024
1 parent 2df9617 commit 3b59572
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,16 @@ fn test_compatible_load_cluster_data() {
.expect("test ClusterDataV2 -> ClusterDataV2");
assert!(cluster_data_v2.mutant_id().is_some());
}

#[test]
fn test_decode_cluster_data() {
let cluster_data = "0f140000100000001b0000000f140000070000004e657276617065f01300007b226465736372697074696f6e223a224e6572766170652c206d756c74692d636861696e20636f6d706f7361626c65206469676974616c206f626a65637473206275696c74206f6e20426974636f696e2e222c22646f62223a7b22766572223a302c226465636f646572223a7b2274797065223a22636f64655f68617368222c2268617368223a22307862383261626435396164653336316130313466306162623639326637316230666562383830363933633363636239356239313337623733353531643837326365227d2c227061747465726e223a2238333039303030303434303030303030383730303030303033373035303030303432303630303030383530363030303063323036303030303035303730303030343830373030303038393037303030306336303730303030303630383030303034343038303030303831303830303030633030383030303030323039303030303433303930303030343330303030303030633030303030303139303030303030303930303030303037303732363537363265373437393730363532613030303030303038303030303030323230303030303030633030303030303064303030303030303130303030303030303131303030303030303830303030303030353030303030303639366436313637363562303034303030303063303030303030313730303030303030373030303030303730373236353736326536323637393930343030303030383030303030303931303430303030306330303030303030643030303030303031303030303030303038303034303030303363303030303030386130303030303064383030303030303236303130303030373430313030303063323031303030303130303230303030356530323030303061633032303030306661303230303030343830333030303039363033303030306534303330303030333230343030303034613030303030303632373436333636373333613266326636323332363633343335333633303636333133373336333733393634333336353333363636333631333633363332333033393631363333343332333536333336333633303634333233383631333233353332363536363337333233343334333436333333333333323335363333363635363233303333333633343333333933333639333034613030303030303632373436333636373333613266326633393335333533323335363536323338333236363339363133313334363333373339333233393334333733363339333433393332363533373636333936323330333233353339333133313634333933333636333536363631333633363632333833313339363533343632363433353338363336343633363433323333363633313639333034613030303030303632373436333636373333613266326636353632333333393331333036323333363533333332363133353635363433393334333633303632363433303634333733353331333633383633333033313632363133313632333836363330333036333633333036363631363633383333363533343634333836323336333736323334333836353631333733393336333733363639333034613030303030303632373436333636373333613266326636343330333433393631333936313633333336313631363433383334333333353335363633373631333533353331333733363333363333383332333833323634363536353330363533363339363136323330333536333332363233373337363333323336333933393632363233323636363233363335363333353633333133363639333034613030303030303632373436333636373333613266326636363332333333393337363233333335363536313332363433303335333033343335333836323633333736353633333933383634363336343333363433393633333333303332333136313631333936343334333436323339363336313331363336323334333433363337333336333334363536323337363333383635363636313639333034613030303030303632373436333636373333613266326636363633363333303634333836363333333933353337333033343332363333373632333233303635333836353636363236313337363233313336333833383334363136323335333736333333333236363635363636313332333633353331363233303334333536323631333533303336363133313332333033313336333033383639333034613030303030303632373436333636373333613266326636323330333133373335333536313331333433313634363433363335363536353332363133303632333336323634333436313631333633343631333136353333363533393339333436313333363333383332363233343332333233373331363436333335363433373330333136333334333836333336333736363336363433353639333034613030303030303632373436333636373333613266326633353334333536323339333436333632333136353633363633323331333733353632333833313633333633303331333333343336363533343631333736353330333533313334333936333631363636333336363633323333333533333333333036333339333933313338363533333335363633393332333036353331333033393639333034613030303030303632373436333636373333613266326633353338333933353330333033343635333933353633333836313334363233383330363633303335363633353333333133343634333333313330333033363337363133373330333333313333333433353331333536343338333236353636363636333332363536333336363536323631333036343634363133333636363333393639333034613030303030303632373436333636373333613266326636333334333236363337363133343336333233383338333036353334363533333636333936323334333133303632363136323335333833333631363136343337333033303635333333363631333533333339363136313336333633373331363233313334333036313332333133373336363536323332363633303334363136333639333034613030303030303632373436333636373333613266326633363334333033353339363633383335333436363633333936353339333033343634333036323634363633343333363236313337333033343330363133393338333836343631333836353339333733333633333036343333363233353336333336313633363636363631333933373336333536333632333636333632363633333639333034613030303030303632373436333636373333613266326633393635333936313636363236313631363436343632363233343636333236333330333133323333333736323634363433323334333033353331333333313337333933333333333833393634333133383331333336363335363633313631333033323634333933373337333133333331333036313632333333303633333733303639333034613030303030303632373436333636373333613266326633313331363233363333333033333635363233373634333833383337363433373631363436353334333533393631363333323337333933353339333733353334363336343335333536363339363633393635333533303333333433353633363536343338363533313635333836363334333736363334333533383331363636313639333034613030303030303632373436333636373333613266326636363331363436333635333033393632363236323336333133393336333136323333363333363331363536363632363636313332333633333631333333383335333133313633363633383339363436323634363536353634333233303336363633363635363336333330333033313631333533323633333136363632333033313639333030623031303030303063303030303030316330303030303030633030303030303730373236353736326536323637363336663663366637326566303030303030303830303030303065373030303030303063303030303030306430303030303030313030303030303030643630303030303033633030303030303437303030303030353230303030303035643030303030303638303030303030373330303030303037653030303030303839303030303030393430303030303039663030303030306161303030303030623530303030303063303030303030306362303030303030303730303030303032333436343634353333343534323037303030303030323334363436343234343436343330373030303030303233343433343433333034363436303730303030303032333431343634353337343633393037303030303030323334313432343633343434333030373030303030303233343533383435343134323435303730303030303032333436343334363338343134333037303030303030323334353431343234333338343230373030303030303233343634363434333833383330303730303030303032333436343634353332343333373037303030303030323334363436343233353337343430373030303030303233343634363431343434313432303730303030303032333435333034353331343533323037303030303030323334313333343133373431343134333030303030303063303030303030316130303030303030613030303030303432363136333662363737323666373536653634323930303030303030383030303030303231303030303030306330303030303030643030303030303031303330303030303030303030303030303030303030303030666630303030303030303030303030303364303030303030306330303030303031343030303030303034303030303030353337353639373432393030303030303038303030303030323130303030303030633030303030303064303030303030303130333030303030303030303030303030303030303030303066663030303030303030303030303030343330303030303030633030303030303161303030303030306130303030303035353730373036353732323036323666363437393239303030303030303830303030303032313030303030303063303030303030306430303030303030313033303030303030303030303030303030303030303030306666303030303030303030303030303034333030303030303063303030303030316130303030303030613030303030303463366637373635373232303632366636343739323930303030303030383030303030303231303030303030306330303030303030643030303030303031303330303030303030303030303030303030303030303030666630303030303030303030303030303431303030303030306330303030303031383030303030303038303030303030343836353631363437373635363137323239303030303030303830303030303032313030303030303063303030303030306430303030303030313033303030303030303030303030303030303030303030306666303030303030303030303030303033643030303030303063303030303030313430303030303030343030303030303464363137333662323930303030303030383030303030303231303030303030306330303030303030643030303030303031303330303030303030303030303030303030303030303030666630303030303030303030303030303430303030303030306330303030303031373030303030303037303030303030343537393635373736353631373232393030303030303038303030303030323130303030303030633030303030303064303030303030303130333030303030303030303030303030303030303030303066663030303030303030303030303030336530303030303030633030303030303135303030303030303530303030303034643666373537343638323930303030303030383030303030303231303030303030306330303030303030643030303030303031303330303030303030303030303030303030303030303030666630303030303030303030303030303364303030303030306330303030303031343030303030303034303030303030343536313732373332393030303030303038303030303030323130303030303030633030303030303064303030303030303130333030303030303030303030303030303030303030303066663030303030303030303030303030336630303030303030633030303030303136303030303030303630303030303035343631373437343666366632393030303030303038303030303030323130303030303030633030303030303064303030303030303130333030303030303030303030303030303030303030303066663030303030303030303030303030343230303030303030633030303030303139303030303030303930303030303034313633363336353733373336663732373932393030303030303038303030303030323130303030303030633030303030303064303030303030303130333030303030303030303030303030303030303030303066663030303030303030303030303030343130303030303030633030303030303138303030303030303830303030303034383631366536343638363536633634323930303030303030383030303030303231303030303030306330303030303030643030303030303031303330303030303030303030303030303030303030303030666630303030303030303030303030303430303030303030306330303030303031373030303030303037303030303030353337303635363336393631366332393030303030303038303030303030323130303030303030633030303030303064303030303030303130333030303030303030303030303030303030303030303066663030303030303030303030303030222c22646e615f6279746573223a31367d7d";
let cluster_data_bytes = hex::decode(cluster_data).unwrap();
let cluster = spore::ClusterDataV2::from_compatible_slice(&cluster_data_bytes)
.map_err(|_| "ClusterDataV2::from_compatible_slice error")
.expect("decode cluster data");
let description = cluster.description();
let hexed = String::from_utf8(description.raw_data().to_vec()).unwrap();
let expected = "{\"description\":\"Nervape, multi-chain composable digital objects built on Bitcoin.\",\"dob\":{\"ver\":0,\"decoder\":{\"type\":\"code_hash\",\"hash\":\"0xb82abd59ade361a014f0abb692f71b0feb880693c3ccb95b9137b73551d872ce\"},\"pattern\":\"830900004400000087000000370500004206000085060000c2060000050700004807000089070000c6070000060800004408000081080000c00800000209000043090000430000000c0000001900000009000000707265762e747970652a00000008000000220000000c0000000d0000000100000000110000000800000005000000696d616765b00400000c0000001700000007000000707265762e62679904000008000000910400000c0000000d0000000100000000800400003c0000008a000000d80000002601000074010000c2010000100200005e020000ac020000fa0200004803000096030000e4030000320400004a00000062746366733a2f2f6232663435363066313736373964336533666361363632303961633432356336363064323861323532656637323434346333333235633665623033363433393369304a00000062746366733a2f2f3935353235656238326639613134633739323934373639343932653766396230323539313164393366356661363662383139653462643538636463643233663169304a00000062746366733a2f2f6562333931306233653332613565643934363062643064373531363863303162613162386630306363306661663833653464386236376234386561373936373669304a00000062746366733a2f2f6430343961396163336161643834333535663761353531373633633832383264656530653639616230356332623737633236393962623266623635633563313669304a00000062746366733a2f2f6632333937623335656132643035303435386263376563393864636433643963333032316161396434346239636131636234343637336334656237633865666169304a00000062746366733a2f2f6663633064386633393537303432633762323065386566626137623136383834616235376333326665666132363531623034356261353036613132303136303869304a00000062746366733a2f2f6230313735356131343164643635656532613062336264346161363461316533653939346133633832623432323731646335643730316334386336376636643569304a00000062746366733a2f2f3534356239346362316563663231373562383163363031333436653461376530353134396361666336663233353333306339393138653335663932306531303969304a00000062746366733a2f2f3538393530303465393563386134623830663035663533313464333130303637613730333133343531356438326566666332656336656261306464613366633969304a00000062746366733a2f2f6334326637613436323838306534653366396234313062616235383361616437303065333661353339616136363731623134306132313736656232663034616369304a00000062746366733a2f2f3634303539663835346663396539303464306264663433626137303430613938386461386539373363306433623536336163666661393736356362366362663369304a00000062746366733a2f2f3965396166626161646462623466326330313233376264643234303531333137393333383964313831336635663161303264393737313331306162333063373069304a00000062746366733a2f2f3131623633303365623764383837643761646534353961633237393539373534636435356639663965353033343563656438653165386634376634353831666169304a00000062746366733a2f2f6631646365303962626236313936316233633631656662666132363361333835313163663839646264656564323036663665636330303161353263316662303169300b0100000c0000001c0000000c000000707265762e6267636f6c6f72ef00000008000000e70000000c0000000d0000000100000000d60000003c00000047000000520000005d00000068000000730000007e00000089000000940000009f000000aa000000b5000000c0000000cb00000007000000234646453345420700000023464642444643070000002344344330464607000000234146453746390700000023414246344430070000002345384541424507000000234643463841430700000023454142433842070000002346464438383007000000234646453243370700000023464642353744070000002346464144414207000000234530453145320700000023413341374141430000000c0000001a0000000a0000004261636b67726f756e642900000008000000210000000c0000000d00000001030000000000000000000000ff000000000000003d0000000c0000001400000004000000537569742900000008000000210000000c0000000d00000001030000000000000000000000ff00000000000000430000000c0000001a0000000a000000557070657220626f64792900000008000000210000000c0000000d00000001030000000000000000000000ff00000000000000430000000c0000001a0000000a0000004c6f77657220626f64792900000008000000210000000c0000000d00000001030000000000000000000000ff00000000000000410000000c000000180000000800000048656164776561722900000008000000210000000c0000000d00000001030000000000000000000000ff000000000000003d0000000c00000014000000040000004d61736b2900000008000000210000000c0000000d00000001030000000000000000000000ff00000000000000400000000c0000001700000007000000457965776561722900000008000000210000000c0000000d00000001030000000000000000000000ff000000000000003e0000000c00000015000000050000004d6f7574682900000008000000210000000c0000000d00000001030000000000000000000000ff000000000000003d0000000c0000001400000004000000456172732900000008000000210000000c0000000d00000001030000000000000000000000ff000000000000003f0000000c0000001600000006000000546174746f6f2900000008000000210000000c0000000d00000001030000000000000000000000ff00000000000000420000000c00000019000000090000004163636573736f72792900000008000000210000000c0000000d00000001030000000000000000000000ff00000000000000410000000c000000180000000800000048616e6468656c642900000008000000210000000c0000000d00000001030000000000000000000000ff00000000000000400000000c00000017000000070000005370656369616c2900000008000000210000000c0000000d00000001030000000000000000000000ff00000000000000\",\"dna_bytes\":16}}";
assert!(hexed == expected);
}

0 comments on commit 3b59572

Please sign in to comment.