(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestCreateDataFile(t *testing.T) { |
| 22 | type args struct { |
| 23 | sLen int |
| 24 | cfg *storage.StorageConfig |
| 25 | } |
| 26 | type rslt struct { |
| 27 | ChunkIdxEnd, KvIdxEnd []uint64 |
| 28 | Miner common.Address |
| 29 | } |
| 30 | tests := []struct { |
| 31 | name string |
| 32 | args args |
| 33 | expected rslt |
| 34 | wantErr bool |
| 35 | }{ |
| 36 | { |
| 37 | "", |
| 38 | args{ |
| 39 | 2, |
| 40 | &storage.StorageConfig{ |
| 41 | L1Contract: common.HexToAddress("0xeeca1001388a5d554D8935E7eaDa08C103E31337"), |
| 42 | Miner: common.HexToAddress("0x04580493117292ba13361D8e9e28609ec112264D"), |
| 43 | KvSize: uint64(131072), |
| 44 | ChunkSize: uint64(131072), |
| 45 | KvEntriesPerShard: uint64(16), |
| 46 | }, |
| 47 | }, |
| 48 | rslt{ |
| 49 | ChunkIdxEnd: []uint64{16, 32}, |
| 50 | KvIdxEnd: []uint64{16, 32}, |
| 51 | Miner: common.HexToAddress("0x04580493117292ba13361D8e9e28609ec112264D"), |
| 52 | }, |
| 53 | false, |
| 54 | }, |
| 55 | } |
| 56 | client, err := ethclient.DialContext(context.Background(), "http://65.108.236.27:8545") |
| 57 | if err != nil { |
| 58 | t.Fatalf("connect to L1 error: %v ", err) |
| 59 | } |
| 60 | defer client.Close() |
| 61 | for _, tt := range tests { |
| 62 | t.Run(tt.name, func(t *testing.T) { |
| 63 | shardList, err := getShardList(context.Background(), client, tt.args.cfg.L1Contract, tt.args.sLen) |
| 64 | if err != nil { |
| 65 | t.Fatalf("getShardList() error: %v ", err) |
| 66 | } |
| 67 | files, err := createDataFile(tt.args.cfg, shardList, ".", ethstorage.ENCODE_BLOB_POSEIDON) |
| 68 | if err != nil { |
| 69 | t.Fatalf("createDataFile() error: %v ", err) |
| 70 | } |
| 71 | defer func() { |
| 72 | for _, fileName := range files { |
| 73 | os.Remove(fileName) |
| 74 | } |
| 75 | }() |
| 76 | for i, fileName := range files { |
| 77 | df, err := ethstorage.OpenDataFile(fileName) |
| 78 | if err != nil { |
nothing calls this directly
no test coverage detected