Skip to content

Commit 757fd9f

Browse files
add nitro enclave integration test (#658)
* wip - add nitro enclave integration test * fix script error * complete deploy step * forgot to detach -d the signatory container
1 parent ce9415a commit 757fd9f

File tree

3 files changed

+68
-11
lines changed

3 files changed

+68
-11
lines changed

.github/workflows/build.yaml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,39 @@ jobs:
106106
run: make release
107107
if: startsWith(github.ref, 'refs/tags/v')
108108

109-
integration-tests:
109+
deploy-ec2:
110110
if: "!startsWith(github.ref, 'refs/tags/v')"
111111
needs: publish
112+
runs-on: ec2
113+
steps:
114+
- name: Login to DockerHub
115+
uses: docker/login-action@v3
116+
if: "!startsWith(github.ref, 'refs/tags/v')"
117+
with:
118+
registry: ghcr.io
119+
username: ${{ github.actor }}
120+
password: ${{ secrets.GITHUB_TOKEN }}
121+
- name: remove slash from image tag
122+
uses: mad9000/actions-find-and-replace-string@5
123+
id: replaceslash
124+
with:
125+
source: ${{ github.head_ref || github.ref_name }}
126+
find: '/'
127+
replace: '-'
128+
if: "!startsWith(github.ref, 'refs/tags/v')"
129+
- name: pull and start the Signatory image under test
130+
env:
131+
IMAGE: ghcr.io/ecadlabs/signatory:${{ steps.replaceslash.outputs.value }}-amd64
132+
run: >
133+
docker pull $IMAGE;
134+
docker stop signatory;
135+
docker rm signatory;
136+
docker run -d --name signatory --privileged --mount type=bind,src=/etc/signatory,dst=/etc/signatory --mount type=bind,src=/var/lib/signatory,dst=/var/lib/signatory -p 6732:6732 -p 9583:9583 --entrypoint "/bin/signatory" $IMAGE -c /etc/signatory/config.yml serve
137+
if: "!startsWith(github.ref, 'refs/tags/v')"
138+
139+
integration-tests:
140+
if: "!startsWith(github.ref, 'refs/tags/v')"
141+
needs: deploy-ec2
112142
runs-on: ubuntu-latest
113143
strategy:
114144
fail-fast: false
@@ -133,6 +163,12 @@ jobs:
133163
find: '/'
134164
replace: '-'
135165
if: "!startsWith(github.ref, 'refs/tags/v')"
166+
- if: ${{ !github.event.pull_request.head.repo.fork && !startsWith(github.ref, 'refs/tags/v')}}
167+
name: Tailscale
168+
uses: tailscale/github-action@v1
169+
with:
170+
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
171+
version: 1.32.2
136172
- name: Run tests
137173
env:
138174
IMAGE: ghcr.io/ecadlabs/signatory:${{ steps.replaceslash.outputs.value }}-amd64
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package vaults_test
2+
3+
import (
4+
"testing"
5+
6+
integrationtest "github.com/ecadlabs/signatory/integration_test/tests"
7+
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestNitroEnclaveVault(t *testing.T) {
12+
out, err := integrationtest.OctezClient("-w", "1", "transfer", "1", "from", "nitro", "to", "alice", "--burn-cap", "0.06425")
13+
require.NoError(t, err)
14+
require.Contains(t, string(out), "Operation successfully injected in the node")
15+
}

integration_test/tezos_scripts/init.sh

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ script_dir="/home/tezos/tezos_scripts"
1919
default_endpoint="http://tezos-node:18731"
2020
manual_baking_endpoint="http://tezos-node-manual-bake:18731"
2121
manual_baking_client_config="/home/tezos/manual-bake-client"
22+
default_signatory="http://signatory:6732"
23+
ec2_signatory="http://10.0.3.122:6732"
2224

2325
client="octez-client"
2426
$client -E $default_endpoint config update
@@ -58,7 +60,7 @@ $client import secret key bootstrap4 $BOOTSTRAP4_SECRET || exit 1
5860
$client import secret key bootstrap5 $BOOTSTRAP5_SECRET || exit 1
5961
$client import secret key activator $ACTIVATOR_SECRET || exit 1
6062
#baker1 is used on the manual bake chain for operation kinds test of baking operations. it is an alias for the bootstrap1 account on the manual bake chain
61-
$client -d $manual_baking_client_config import secret key baker1 http://signatory:6732/tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx || exit 1
63+
$client -d $manual_baking_client_config import secret key baker1 $default_signatory/tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx || exit 1
6264

6365
protocol_hash=$(grep "^$protocol_name" $script_dir/protocol_hash)
6466
protocol_full_name=$(cat $tezos_script_dir/active_protocol_versions | grep -E '^[0-9]{3}-[A-Za-z]+$' | grep "$protocol_name$")
@@ -80,50 +82,54 @@ $client -E $manual_baking_endpoint -block genesis activate protocol $protocol_ha
8082
# These keys are used in the integration tests and should be imported after the protocol activation.
8183

8284
# alice
83-
$client import secret key alice http://signatory:6732/tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb
85+
$client import secret key alice $default_signatory/tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb
8486
$client --wait none transfer 100000 from bootstrap2 to alice --burn-cap 0.07
8587
$client bake for --minimal-timestamp
8688

8789
# bob
88-
$client import secret key bob http://signatory:6732/tz1aSkwEot3L2kmUvcoxzjMomb9mvBNuzFK6
90+
$client import secret key bob $default_signatory/tz1aSkwEot3L2kmUvcoxzjMomb9mvBNuzFK6
8991
$client --wait none transfer 100000 from bootstrap2 to bob --burn-cap 0.07
9092
$client bake for --minimal-timestamp
9193

9294
# opstest
93-
$client import secret key opstest http://signatory:6732/tz1RKGhRF4TZNCXEfwyqZshGsVfrZeVU446B
95+
$client import secret key opstest $default_signatory/tz1RKGhRF4TZNCXEfwyqZshGsVfrZeVU446B
9496
$client --wait none transfer 100000 from bootstrap2 to opstest --burn-cap 0.07
9597
$client bake for --minimal-timestamp
9698

9799
# opstest1
98-
$client import secret key opstest1 http://signatory:6732/tz1R8HJMzVdZ9RqLCknxeq9w5rSbiqJ41szi
100+
$client import secret key opstest1 $default_signatory/tz1R8HJMzVdZ9RqLCknxeq9w5rSbiqJ41szi
99101
$client --wait none transfer 100000 from bootstrap2 to opstest1 --burn-cap 0.07
100102
$client bake for --minimal-timestamp
101103

102104
# tz1alias
103-
$client import secret key tz1alias http://signatory:6732/tz1dSrM2D7XcWPhdZpDxzNkmVLvdWSxApXaR
105+
$client import secret key tz1alias $default_signatory/tz1dSrM2D7XcWPhdZpDxzNkmVLvdWSxApXaR
104106
$client --wait none transfer 100000 from bootstrap2 to tz1alias --burn-cap 0.07
105107
$client bake for --minimal-timestamp
106108

107109
# tz2alias
108-
$client import secret key tz2alias http://signatory:6732/tz2QPsZoZse4eeahhg5DdfnBDB4VbU1PwgxN
110+
$client import secret key tz2alias $default_signatory/tz2QPsZoZse4eeahhg5DdfnBDB4VbU1PwgxN
109111
$client --wait none transfer 100000 from bootstrap2 to tz2alias --burn-cap 0.07
110112
$client bake for --minimal-timestamp
111113

112114
# tz3alias
113-
$client import secret key tz3alias http://signatory:6732/tz3ZbCsUveF3Q6WUNkThT1wyJyhPunanaAXK
115+
$client import secret key tz3alias $default_signatory/tz3ZbCsUveF3Q6WUNkThT1wyJyhPunanaAXK
114116
$client --wait none transfer 100000 from bootstrap2 to tz3alias --burn-cap 0.07
115117
$client bake for --minimal-timestamp
116118

117119
# tz4alias
118-
$client import secret key tz4alias http://signatory:6732/tz4XXtsYav3fZz2FSDa7hcx4F8sh8SaDWNME
120+
$client import secret key tz4alias $default_signatory/tz4XXtsYav3fZz2FSDa7hcx4F8sh8SaDWNME
119121
$client --wait none transfer 100000 from bootstrap2 to tz4alias --burn-cap 0.07
120122
$client bake for --minimal-timestamp
121123

122124
# speculos
123-
$client import secret key speculos http://signatory:6732/tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA
125+
$client import secret key speculos $default_signatory/tz1RVYaHiobUKXMfJ47F7Rjxx5tu3LC35WSA
124126
$client --wait none transfer 100000 from bootstrap2 to speculos --burn-cap 0.07
125127
$client bake for --minimal-timestamp
126128

129+
$client import secret key nitro $ec2_signatory/tz2Gx28QytbwB9xZYUbc14HrVTJkwwYy4WAk
130+
$client --wait none transfer 100000 from bootstrap2 to nitro --burn-cap 0.07
131+
$client bake for --minimal-timestamp
132+
127133
echo "All keys imported successfully!"
128134

129135
octez-baker run remotely --without-dal --liquidity-baking-toggle-vote pass

0 commit comments

Comments
 (0)