Exemple #1
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)
	}
}
Exemple #2
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)
	}
}
func TestHandleV2GetReceipt(t *testing.T) {
	state := testHelper.CreateAndPopulateTestState()
	//Start(state)

	hashkey := new(HashRequest)
	hashkey.Hash = "be5fb8c3ba92c0436269fab394ff7277c67e9b2de4431b723ce5d89799c0b93a"

	resp, jErr := HandleV2Receipt(state, hashkey)
	if jErr != nil {
		t.Errorf("%v", jErr)
		return
	}

	dbo := state.GetAndLockDB()
	defer state.UnlockDB()

	marshalled, err := json.Marshal(resp.(*ReceiptResponse).Receipt)
	if err != nil {
		t.Error(err)
	}
	t.Logf("Resp - %s", marshalled)

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