Skip to content
Snippets Groups Projects
Commit a6470ef4 authored by Lyuben Penkovski's avatar Lyuben Penkovski
Browse files

Fix failing unit tests by slowing them down

W3C has rate limiter and resolving of base JSONLD contexts
fails if the test cases are executed too fast. This commit
artificially slows down test case execution, so tests could
pass without any significant changes.

Another option to resolve this issue is to expose these
base contexts at another URL without rate limiting just for use
in tests, but it will be more complicated solution and a lot more
unstable as the project tests will depend on our server running
properly 24x7 indefinely in the future.
parent 610e84ef
No related branches found
No related tags found
No related merge requests found
Pipeline #67101 failed with stages
in 2 minutes
......@@ -8,6 +8,7 @@ import (
"encoding/json"
"net/http"
"testing"
"time"
"github.com/hyperledger/aries-framework-go/pkg/doc/verifiable"
"github.com/square/go-jose/v3"
......@@ -322,19 +323,6 @@ func TestService_CredentialProof(t *testing.T) {
errkind: errors.Internal,
errtext: "error getting signing key",
},
{
name: "valid credential but signer returns internal error",
namespace: "transit",
keyname: "key2",
credential: []byte(validCredential),
signer: &signerfakes.FakeVault{
KeyStub: func(ctx context.Context, namespace, key string) (*signer.VaultKey, error) {
return nil, errors.New(errors.Internal)
},
},
errkind: errors.Internal,
errtext: "error getting signing key",
},
{
name: "valid credential but signer returns unsupported key type",
namespace: "transit",
......@@ -452,6 +440,12 @@ func TestService_CredentialProof(t *testing.T) {
assert.NotEmpty(t, vc.Proofs[0]["jws"])
}
})
// Wait after each test case, because W3C domain has
// rate limiter, and resolving of VC base JSONLD contexts
// (i.e. https://www.w3.org/2018/credentials/v1)
// fails, which makes the tests fail.
time.Sleep(1 * time.Second)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment