github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/stellar/stellarsvc/identify_test.go (about) 1 package stellarsvc 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 9 "github.com/keybase/client/go/engine" 10 "github.com/keybase/client/go/kbtest" 11 "github.com/keybase/client/go/libkb" 12 "github.com/keybase/client/go/protocol/keybase1" 13 ) 14 15 func TestIdentifyWithStellarAccount(t *testing.T) { 16 tcs, cleanup := setupTestsWithSettings(t, []usetting{usettingFull, usettingFull}) 17 defer cleanup() 18 19 // Create wallet as user 0. User 0 will be the one being identified. 20 acceptDisclaimer(tcs[0]) 21 accountID := getPrimaryAccountID(tcs[0]) 22 23 idUI := &kbtest.FakeIdentifyUI{} 24 arg := keybase1.Identify2Arg{ 25 UserAssertion: tcs[0].Fu.Username, 26 AlwaysBlock: true, 27 IdentifyBehavior: keybase1.TLFIdentifyBehavior_CLI, 28 } 29 30 // Run identify as user 1. 31 tc := tcs[1] 32 33 uis := libkb.UIs{ 34 LogUI: tc.G.UI.GetLogUI(), 35 IdentifyUI: idUI, 36 } 37 38 eng := engine.NewResolveThenIdentify2(tc.G, &arg) 39 m := libkb.NewMetaContextForTest(tc.TestContext).WithUIs(uis) 40 err := engine.RunEngine2(m, eng) 41 require.NoError(t, err) 42 res, err := eng.Result(m) 43 require.NoError(t, err) 44 45 // Check if Stellar account ID ended up in UPK 46 require.NotNil(t, res.Upk.Current.StellarAccountID) 47 require.Equal(t, accountID.String(), *res.Upk.Current.StellarAccountID) 48 49 // Check that it went through identify UI. 50 require.Len(t, idUI.StellarAccounts, 1) 51 acc0 := idUI.StellarAccounts[0] 52 t.Logf("Got StellarAccount in identify ui: %+v", acc0) 53 require.Equal(t, accountID.String(), acc0.AccountID) 54 require.Equal(t, fmt.Sprintf("%s*keybase.io", tcs[0].Fu.Username), acc0.FederationAddress) 55 require.NotEmpty(t, acc0.SigID) 56 }