github.com/sixexorg/magnetic-ring@v0.0.0-20191119090307-31705a21e419/store/mainchain/storages/receipt_store_test.go (about) 1 package storages_test 2 3 import ( 4 "os" 5 "testing" 6 7 "github.com/magiconair/properties/assert" 8 "github.com/sixexorg/magnetic-ring/common" 9 "github.com/sixexorg/magnetic-ring/core/mainchain/types" 10 "github.com/sixexorg/magnetic-ring/store/mainchain/storages" 11 ) 12 13 func TestReceiptStore(t *testing.T) { 14 dbdir := "test" 15 defer os.RemoveAll(dbdir) 16 store, _ := storages.NewReceiptStore(dbdir, false) 17 txHash, _ := common.StringToHash("6s3q52rn2fhv38ssk14zkx4zsk9rctv3ugw7tapanu25ucskb18h====") 18 receipt := &types.Receipt{ 19 Status: true, 20 TxHash: txHash, 21 GasUsed: 1000, 22 } 23 store.NewBatch() 24 store.BatchSave(types.Receipts{receipt}) 25 err := store.CommitTo() 26 if err != nil { 27 t.Fail() 28 t.Error(err) 29 return 30 } 31 receiptGet, err := store.GetReceipt(txHash) 32 if err != nil { 33 t.Fail() 34 t.Error(err) 35 return 36 } 37 assert.Equal(t, receipt, receiptGet) 38 }