@@ -430,3 +430,76 @@ func TestParseTychoBlockErrorCases(t *testing.T) {
430430 })
431431 }
432432}
433+
434+ // TestParseTychoShardAccount tests parsing of shard account data fetched from Tycho.
435+ func TestParseTychoShardAccount (t * testing.T ) {
436+ client , err := NewClient ()
437+ if err != nil {
438+ t .Fatalf ("Failed to create client: %v" , err )
439+ }
440+ defer client .Close ()
441+
442+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
443+ defer cancel ()
444+
445+ // Test with a zero address (most likely to return some data)
446+ testAddress := make ([]byte , 32 )
447+
448+ accountInfo , err := client .GetShardAccount (ctx , 0 , testAddress , false )
449+ if err != nil {
450+ t .Fatalf ("GetShardAccount failed, account might not exists: %v" , err )
451+ }
452+
453+ if len (accountInfo .AccountState ) == 0 {
454+ t .Skip ("No account data to test parsing" )
455+ }
456+
457+ // Verify that ParseShardAccount works
458+ if accountInfo .ParsedAccountState == nil {
459+ t .Error ("ParsedAccountState should not be nil when AccountState exists" )
460+ }
461+
462+ t .Logf ("Successfully parsed account data: %d bytes -> cell with %d bits, %d refs" ,
463+ len (accountInfo .AccountState ),
464+ accountInfo .ParsedAccountState .BitsAvailableForRead (),
465+ accountInfo .ParsedAccountState .RefsAvailableForRead ())
466+ }
467+
468+ // TestParseTychoShardAccountAtSeqno tests fetching and parsing account data at a specific seqno
469+ func TestParseTychoShardAccountAtSeqno (t * testing.T ) {
470+ client , err := NewClient ()
471+ if err != nil {
472+ t .Fatalf ("Failed to create client: %v" , err )
473+ }
474+ defer client .Close ()
475+
476+ ctx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
477+ defer cancel ()
478+
479+ // Get status to find a valid seqno
480+ status , err := client .GetStatus (ctx )
481+ if err != nil {
482+ t .Fatalf ("Failed to get status: %v" , err )
483+ }
484+
485+ if status .McStateInfo == nil || status .McStateInfo .McSeqno < 2 {
486+ t .Skip ("Need at least seqno 2 for historical testing" )
487+ }
488+
489+ // Test with a historical seqno
490+ targetSeqno := status .McStateInfo .McSeqno - 1
491+ testAddress := make ([]byte , 32 ) // Zero address
492+
493+ accountInfo , err := client .GetShardAccountAtSeqno (ctx , 0 , testAddress , false , masterchainWorkchain , masterchainShard , targetSeqno )
494+ if err != nil {
495+ t .Logf ("GetShardAccountAtSeqno failed: %v" , err )
496+ return // Expected for non-existent accounts
497+ }
498+
499+ // If we got data, verify parsing works
500+ if len (accountInfo .AccountState ) > 0 && accountInfo .ParsedAccountState == nil {
501+ t .Error ("ParsedAccountState should not be nil when AccountState exists" )
502+ }
503+
504+ t .Logf ("Historical account parsing test completed" )
505+ }
0 commit comments