Esempio n. 1
0
func TestV2HandleEntryCreditBalance(t *testing.T) {
	state := testHelper.CreateAndPopulateTestState()
	eckey := testHelper.NewECAddressPublicKeyString(0)
	req := new(AddressRequest)
	req.Address = eckey

	resp, err := HandleV2EntryCreditBalance(state, req)
	if err != nil {
		t.Errorf("%v", err)
	}

	var expectedAmount int64 = 2000

	if resp.(*EntryCreditBalanceResponse).Balance != expectedAmount {
		t.Errorf("Invalid balance returned - %v vs %v", resp.(*EntryCreditBalanceResponse).Balance, expectedAmount)
	}

	eckey = testHelper.NewECAddressString(0)
	req = new(AddressRequest)
	req.Address = eckey

	resp, err = HandleV2EntryCreditBalance(state, req)
	if err != nil {
		t.Errorf("%v", err)
	}

	if resp.(*EntryCreditBalanceResponse).Balance != expectedAmount {
		t.Errorf("Invalid balance returned - %v vs %v", resp.(*EntryCreditBalanceResponse).Balance, expectedAmount)
	}
}
Esempio n. 2
0
func TestHandleEntryCreditBalance(t *testing.T) {
	context := testHelper.CreateWebContext()
	eckey := testHelper.NewECAddressPublicKeyString(0)

	HandleEntryCreditBalance(context, eckey)

	expectedAmount := "2000"
	if strings.Contains(testHelper.GetBody(context), expectedAmount) == false {
		t.Errorf("%v", testHelper.GetBody(context))
	}
	testHelper.ClearContextResponseWriter(context)

	eckey = testHelper.NewECAddressString(0)

	HandleEntryCreditBalance(context, eckey)

	if strings.Contains(testHelper.GetBody(context), expectedAmount) == false {
		t.Errorf("%v", testHelper.GetBody(context))
	}
}