Skip to content

Commit

Permalink
remove test that will fail when the server gets more restrictive on a…
Browse files Browse the repository at this point in the history
…ccount bundle migrations (#14729)
  • Loading branch information
xgess committed Nov 16, 2018
1 parent 244863b commit ab1fbd0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
3 changes: 2 additions & 1 deletion go/libkb/features.go
Expand Up @@ -64,7 +64,8 @@ type FeatureFlagSet struct {
}

const (
FeatureFTL = Feature("ftl")
FeatureFTL = Feature("ftl")
FeatureStellarAcctBundles = Feature("stellar_acct_bundles")
)

// NewFeatureFlagSet makes a new set of feature flags.
Expand Down
14 changes: 14 additions & 0 deletions go/stellar/stellar.go
Expand Up @@ -228,6 +228,20 @@ func ImportSecretKeyAccountBundle(ctx context.Context, g *libkb.GlobalContext, s
if err != nil {
return err
}

// turn on the feature flag for the v2 stellar account bundles
m := libkb.NewMetaContext(ctx, g)
_, err = g.API.Post(libkb.APIArg{
Endpoint: "test/feature",
SessionType: libkb.APISessionTypeREQUIRED,
Args: libkb.HTTPArgs{
"feature": libkb.S{Val: string(libkb.FeatureStellarAcctBundles)},
"value": libkb.I{Val: 1},
"cache_sec": libkb.I{Val: 100},
},
MetaContext: m,
})

if err := remote.PostBundleRestricted(ctx, g, acctBundle); err != nil {
g.Log.CDebugf(ctx, "ImportSecretKey PostAccountBundle error: %s", err)
return err
Expand Down
39 changes: 18 additions & 21 deletions go/stellar/stellarsvc/service_test.go
Expand Up @@ -881,11 +881,11 @@ func TestMakeAccountMobileOnlyOnDesktop(t *testing.T) {
err = stellar.ImportSecretKeyAccountBundle(context.Background(), tc.G, s1, false, "vault")
require.NoError(t, err)

acctBundle, version, err := remote.FetchAccountBundle(context.Background(), tc.G, a1)
rev2AcctBundle, version, err := remote.FetchAccountBundle(context.Background(), tc.G, a1)
require.NoError(t, err)
require.Equal(t, stellar1.BundleVersion_V2, version)
require.Equal(t, stellar1.BundleRevision(2), acctBundle.Revision)
// NOTE: we're using this acctBundle later...
require.Equal(t, stellar1.BundleRevision(2), rev2AcctBundle.Revision)
// NOTE: we're using this rev2AcctBundle later...

err = remote.MakeAccountMobileOnly(context.Background(), tc.G, a1)
require.NoError(t, err)
Expand All @@ -907,29 +907,26 @@ func TestMakeAccountMobileOnlyOnDesktop(t *testing.T) {
}
require.Equal(t, libkb.SCStellarDeviceNotMobile, aerr.Code)

primaryAcctName := fmt.Sprintf("%s's account", tc.Fu.Username)

// can fetch the bundle, but it won't have secrets
bundle, _, err := remote.Fetch(context.Background(), tc.G)
require.NoError(t, err)
require.Equal(t, stellar1.BundleRevision(3), bundle.Revision)
require.Len(t, bundle.Accounts, 2)
require.Equal(t, stellar1.AccountMode_USER, bundle.Accounts[0].Mode)
require.True(t, bundle.Accounts[0].IsPrimary)
require.Len(t, bundle.Accounts[0].Signers, 0)
require.Equal(t, primaryAcctName, bundle.Accounts[0].Name)
require.Equal(t, stellar1.AccountMode_MOBILE, bundle.Accounts[1].Mode)
require.False(t, bundle.Accounts[1].IsPrimary)
require.Len(t, bundle.Accounts[1].Signers, 0)
require.Equal(t, "vault", bundle.Accounts[1].Name)
// TODO: reintroduce this test after the server has been updated
// primaryAcctName := fmt.Sprintf("%s's account", tc.Fu.Username)
// for the desired behavior from the two fetch endpoints
// rev3AcctBundle, _, err := remote.Fetch(context.Background(), tc.G)
// require.NoError(t, err)
// require.Equal(t, stellar1.BundleVersion_V2, version)
// require.Equal(t, stellar1.BundleRevision(3), rev3AcctBundle.Revision)
// require.Equal(t, primaryAcctName, rev3AcctBundle.Accounts[0].Name)
// require.Equal(t, stellar1.AccountMode_MOBILE, rev3AcctBundle.Accounts[1].Mode)
// require.False(t, rev3AcctBundle.Accounts[1].IsPrimary)
// require.Len(t, rev3AcctBundle.Accounts[1].Signers, 0)
// require.Equal(t, "vault", rev3AcctBundle.Accounts[1].Name)

// try posting an old bundle we got previously
err = remote.PostBundleRestricted(context.Background(), tc.G, acctBundle)
err = remote.PostBundleRestricted(context.Background(), tc.G, rev2AcctBundle)
require.Error(t, err)

// tinker with it
acctBundle.Revision = 4
err = remote.PostBundleRestricted(context.Background(), tc.G, acctBundle)
rev2AcctBundle.Revision = 4
err = remote.PostBundleRestricted(context.Background(), tc.G, rev2AcctBundle)
require.Error(t, err)
}

Expand Down

0 comments on commit ab1fbd0

Please sign in to comment.