|
| 1 | +// Copyright 2020 DSR Corporation |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package dclauth_test_cli |
| 16 | + |
| 17 | +import ( |
| 18 | + "github.com/stretchr/testify/require" |
| 19 | + "github.com/zigbee-alliance/distributed-compliance-ledger/integration_tests/cli_go/helpers" |
| 20 | + testconstants "github.com/zigbee-alliance/distributed-compliance-ledger/integration_tests/constants" |
| 21 | + "github.com/zigbee-alliance/distributed-compliance-ledger/integration_tests/utils" |
| 22 | + dclauthtypes "github.com/zigbee-alliance/distributed-compliance-ledger/x/dclauth/types" |
| 23 | + "testing" |
| 24 | +) |
| 25 | + |
| 26 | +func TestAuthDemoCLI(t *testing.T) { |
| 27 | + suite := utils.SetupTest(t, testconstants.ChainID, false) |
| 28 | + |
| 29 | + jack := testconstants.JackAccount |
| 30 | + alice := testconstants.AliceAccount |
| 31 | + |
| 32 | + user1 := helpers.CreateAccountInfo(&suite) |
| 33 | + |
| 34 | + // Propose user1 account by jack |
| 35 | + txResult, err := ProposeAccount(user1.Address, user1.Key, dclauthtypes.NodeAdmin, jack) |
| 36 | + require.NoError(suite.T, err) |
| 37 | + require.Equal(suite.T, txResult.Code, uint32(0)) |
| 38 | + |
| 39 | + // Approve user1 account by alice |
| 40 | + txResult, err = ApproveAccount(user1.Address, alice) |
| 41 | + require.NoError(suite.T, err) |
| 42 | + require.Equal(suite.T, txResult.Code, uint32(0)) |
| 43 | + |
| 44 | + // await transaction is written |
| 45 | + _, err = helpers.AwaitTxConfirmation(txResult.TxHash) |
| 46 | + require.NoError(suite.T, err) |
| 47 | + |
| 48 | + // Query list of all active accounts |
| 49 | + accounts, err := QueryAccounts() |
| 50 | + require.NoError(suite.T, err) |
| 51 | + require.True(suite.T, AccountIsInList(user1.Address, accounts.Account)) |
| 52 | + |
| 53 | + // Query user1 account |
| 54 | + account, err := QueryAccount(user1.Address) |
| 55 | + require.NoError(suite.T, err) |
| 56 | + require.Equal(suite.T, account.Address, user1.Address) |
| 57 | +} |
0 commit comments