github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/engine/prove_check_test.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package engine 5 6 import ( 7 "testing" 8 9 "github.com/keybase/client/go/libkb" 10 keybase1 "github.com/keybase/client/go/protocol/keybase1" 11 "github.com/stretchr/testify/require" 12 ) 13 14 func TestProveCheck(t *testing.T) { 15 doWithSigChainVersions(func(sigVersion libkb.SigVersion) { 16 tc := SetupEngineTest(t, "proveCheck") 17 defer tc.Cleanup() 18 19 fu := CreateAndSignupFakeUser(tc, "prove") 20 21 proveCheck := func(sigID keybase1.SigID, noText bool) { 22 checkEng := NewProveCheck(tc.G, sigID) 23 m := libkb.NewMetaContextTODO(tc.G) 24 err := RunEngine2(m, checkEng) 25 require.NoError(t, err) 26 27 found, status, state, text := checkEng.Results() 28 require.True(t, found) 29 require.Equal(t, keybase1.ProofStatus_OK, status) 30 require.Equal(t, keybase1.ProofState_OK, state) 31 if noText { 32 require.Zero(t, len(text)) 33 } else { 34 require.NotZero(t, len(text)) 35 } 36 } 37 38 proveUI, sigID, err := proveRooter(tc.G, fu, sigVersion) 39 require.NoError(t, err) 40 require.False(t, proveUI.overwrite) 41 require.False(t, proveUI.warning) 42 require.False(t, proveUI.recheck) 43 require.True(t, proveUI.checked) 44 proveCheck(sigID, false /* noText */) 45 46 sigID = proveGubbleSocial(tc, fu, sigVersion) 47 proveCheck(sigID, true /* noText */) 48 }) 49 }