(t *testing.T)
| 169 | } |
| 170 | |
| 171 | func TestReadPrivateReceipt(t *testing.T) { |
| 172 | type args struct { |
| 173 | txHash common.Hash |
| 174 | db database.Database |
| 175 | } |
| 176 | |
| 177 | db := getTestDB() |
| 178 | receipt := getTestReceipt() |
| 179 | |
| 180 | WritePrivateReceipt(receipt, common.Hash{}, db) |
| 181 | r, _ := ReadPrivateReceipt(common.Hash{}, db) |
| 182 | fmt.Println(r) |
| 183 | |
| 184 | tests := []struct { |
| 185 | name string |
| 186 | args args |
| 187 | want *types.Receipt |
| 188 | wantErr bool |
| 189 | }{ |
| 190 | { |
| 191 | name: "Read private transaction receipt", |
| 192 | args: args{ |
| 193 | txHash: common.Hash{}, |
| 194 | db: db, |
| 195 | }, |
| 196 | want: receipt, |
| 197 | wantErr: false, |
| 198 | }, |
| 199 | { |
| 200 | name: "Read a non-existed private transaction receipt", |
| 201 | args: args{ |
| 202 | txHash: common.BytesToHash([]byte{1, 1, 1, 1, 1, 1, 1, 1}), |
| 203 | db: db, |
| 204 | }, |
| 205 | want: nil, |
| 206 | wantErr: true, |
| 207 | }, |
| 208 | } |
| 209 | for _, tt := range tests { |
| 210 | t.Run(tt.name, func(t *testing.T) { |
| 211 | got, err := ReadPrivateReceipt(tt.args.txHash, tt.args.db) |
| 212 | if (err != nil) != tt.wantErr { |
| 213 | t.Errorf("ReadPrivateReceipt() error = %v, wantErr %v", err, tt.wantErr) |
| 214 | return |
| 215 | } |
| 216 | |
| 217 | var gotBytes, wantBytes []byte |
| 218 | if got != nil { |
| 219 | gotBytes, err = rlp.EncodeToBytes(got) |
| 220 | |
| 221 | } |
| 222 | if tt.want != nil { |
| 223 | wantBytes, err = rlp.EncodeToBytes(tt.want) |
| 224 | } |
| 225 | if !reflect.DeepEqual(gotBytes, wantBytes) { |
| 226 | t.Errorf("ReadPrivateReceipt() = %v, want %v", got, tt.want) |
| 227 | } |
| 228 | }) |
nothing calls this directly
no test coverage detected