Compare commits
3 Commits
7885c7f8fa
...
5317ed3bd5
Author | SHA1 | Date | |
---|---|---|---|
5317ed3bd5 | |||
e0636593fb | |||
47dbf176da |
@ -3827,3 +3827,70 @@ func TestClearTemporaryValue(t *testing.T) {
|
||||
// assert that the temp value is empty
|
||||
assert.Equal(t, currentTempValue, []byte(""))
|
||||
}
|
||||
|
||||
func TestGetSuggestedAlias(t *testing.T) {
|
||||
ctx, store := InitializeTestStore(t)
|
||||
sessionId := "session123"
|
||||
alias := "foo.sarafu.eth"
|
||||
|
||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||
|
||||
h := &MenuHandlers{
|
||||
userdataStore: store,
|
||||
}
|
||||
|
||||
//Set a suggested alias a temporary value that will be expected to be in the result content
|
||||
err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(alias))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
res, err := h.GetSuggestedAlias(ctx, "getsuggested_alias", []byte(""))
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
assert.Equal(t, res.Content, alias)
|
||||
|
||||
}
|
||||
|
||||
func TestConfirmNewAlias(t *testing.T) {
|
||||
ctx, store := InitializeTestStore(t)
|
||||
sessionId := "session123"
|
||||
expectedSavedAlias := "fooo.sarafu.eth"
|
||||
|
||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||
|
||||
//Set a temporary alias that is suggested,confirm if the the current new alias after confirmation
|
||||
err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(expectedSavedAlias))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mockState := state.NewState(128)
|
||||
|
||||
fm, err := NewFlagManager(flagsPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
h := &MenuHandlers{
|
||||
userdataStore: store,
|
||||
st: mockState,
|
||||
flagManager: fm,
|
||||
}
|
||||
flag_alias_set, _ := h.flagManager.GetFlag("flag_alias_set")
|
||||
|
||||
expectedResult := resource.Result{
|
||||
FlagSet: []uint32{flag_alias_set},
|
||||
}
|
||||
|
||||
res, err := h.ConfirmNewAlias(ctx, "confirm_new_alias", []byte(""))
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
accAlias, err := store.ReadEntry(ctx, sessionId, storedb.DATA_ACCOUNT_ALIAS)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, expectedResult, res)
|
||||
assert.Equal(t, expectedSavedAlias, string(accAlias))
|
||||
}
|
||||
|
@ -140,6 +140,39 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "menu_my_account_my_alias",
|
||||
"steps": [
|
||||
{
|
||||
"input": "",
|
||||
"expectedContent": "{balance}\n\n1:Send\n2:My Vouchers\n3:My Account\n4:Help\n9:Quit"
|
||||
},
|
||||
{
|
||||
"input": "3",
|
||||
"expectedContent": "My Account\n1:Profile\n2:Change language\n3:Check balances\n4:Check statement\n5:PIN options\n6:My Address\n7:My Alias\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "",
|
||||
"expectedContent": "My Account\n1:Profile\n2:Change language\n3:Check balances\n4:Check statement\n5:PIN options\n6:My Address\n7:My Alias\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "7",
|
||||
"expectedContent": "Current alias: Not Provided\nEdit my alias:\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "foo",
|
||||
"expectedContent": "Your full alias will be: \nPlease enter your PIN to confirm: \n\n0:Back"
|
||||
},
|
||||
{
|
||||
"input": "1234",
|
||||
"expectedContent": "Your alias has been updated successfully\n0:Back\n9:Quit"
|
||||
},
|
||||
{
|
||||
"input": "0",
|
||||
"expectedContent": "{balance}\n\n1:Send\n2:My Vouchers\n3:My Account\n4:Help\n9:Quit"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "menu_my_account_reset_others_pin_with_unregistered_number",
|
||||
"steps": [
|
||||
|
Loading…
Reference in New Issue
Block a user