3cc98de3ee
Make changes so that we only import the necessary files from the console package so that the generated wasm code is as small as possible. This change gets the compiled wasm code down to 8.6MB uncompressed and 2MB when compressed with `gzip --best`. https://review.dev.storj.io/c/storj/storj/+/3396 Change-Id: Ifdd4be285810757b46bbbe43327c0d0139e5f8f7
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
// Copyright (C) 2020 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package consolewasm_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"storj.io/common/testcontext"
|
|
"storj.io/storj/private/testplanet"
|
|
console "storj.io/storj/satellite/console/consolewasm"
|
|
)
|
|
|
|
// TestGenerateAccessGrant confirms that the access grant produced by the wasm access code
|
|
// is the same as the code the uplink cli uses to create access grants.
|
|
func TestGenerateAccessGrant(t *testing.T) {
|
|
testplanet.Run(t, testplanet.Config{
|
|
SatelliteCount: 1, StorageNodeCount: 0, UplinkCount: 1,
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
satellitePeer := planet.Satellites[0]
|
|
satelliteNodeURL := satellitePeer.NodeURL().String()
|
|
|
|
uplinkPeer := planet.Uplinks[0]
|
|
apiKeyString := uplinkPeer.Projects[0].APIKey
|
|
projectID := uplinkPeer.Projects[0].ID.String()
|
|
|
|
passphrase := "supersecretpassphrase"
|
|
|
|
wasmAccessString, err := console.GenAccessGrant(satelliteNodeURL, apiKeyString, passphrase, projectID)
|
|
require.NoError(t, err)
|
|
|
|
uplinkCliAccess, err := uplinkPeer.Config.RequestAccessWithPassphrase(ctx, satelliteNodeURL, apiKeyString, passphrase)
|
|
require.NoError(t, err)
|
|
uplinkCliAccessString, err := uplinkCliAccess.Serialize()
|
|
require.NoError(t, err)
|
|
require.Equal(t, wasmAccessString, uplinkCliAccessString)
|
|
})
|
|
}
|