Example #1
0
func TestHandleGetUnanchoredReceipt(t *testing.T) {
	context := testHelper.CreateWebContext()
	hash := "68a503bd3d5b87d3a41a737e430d2ce78f5e556f6a9269859eeb1e053b7f92f7"

	HandleGetReceipt(context, hash)

	j := testHelper.GetRespMap(context)

	if j == nil {
		t.Error("Receipt not found!")
		return
	}

	dbo := context.Server.Env["state"].(interfaces.IState).GetAndLockDB()
	defer context.Server.Env["state"].(interfaces.IState).UnlockDB()

	receipt := j["receipt"].(map[string]interface{})
	marshalled, err := json.Marshal(receipt)
	if err != nil {
		t.Error(err)
	}

	err = receipts.VerifyFullReceipt(dbo, string(marshalled))
	if err != nil {
		t.Logf("receipt - %v", j)
		t.Error(err)
	}
}
Example #2
0
func TestHandleGetReceipt(t *testing.T) {
	context := testHelper.CreateWebContext()
	hash := "be5fb8c3ba92c0436269fab394ff7277c67e9b2de4431b723ce5d89799c0b93a"

	HandleGetReceipt(context, hash)

	j := testHelper.GetRespMap(context)

	if j == nil {
		t.Error("Receipt not found!")
		return
	}

	dbo := context.Server.Env["state"].(interfaces.IState).GetAndLockDB()
	defer context.Server.Env["state"].(interfaces.IState).UnlockDB()

	receipt := j["receipt"].(map[string]interface{})
	marshalled, err := json.Marshal(receipt)
	if err != nil {
		t.Error(err)
	}

	err = receipts.VerifyFullReceipt(dbo, string(marshalled))
	if err != nil {
		t.Logf("receipt - %v", j)
		t.Error(err)
	}
}