Repository navigation
Expand file tree
/
Copy pathhelpers_test.go
More file actions
59 lines (48 loc) · 1.53 KB
/
Copy pathhelpers_test.go
File metadata and controls
59 lines (48 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package txnbuild
import (
"testing"
"github.com/stellar/go/keypair"
"github.com/stellar/go/support/errors"
"github.com/stellar/go/xdr"
"github.com/stretchr/testify/assert"
)
func newKeypair0() *keypair.Full {
// Address: GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3
return newKeypair("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R")
}
func newKeypair1() *keypair.Full {
// Address: GAS4V4O2B7DW5T7IQRPEEVCRXMDZESKISR7DVIGKZQYYV3OSQ5SH5LVP
return newKeypair("SBMSVD4KKELKGZXHBUQTIROWUAPQASDX7KEJITARP4VMZ6KLUHOGPTYW")
}
func newKeypair2() *keypair.Full {
// Address: GB7BDSZU2Y27LYNLALKKALB52WS2IZWYBDGY6EQBLEED3TJOCVMZRH7H
return newKeypair("SBZVMB74Z76QZ3ZOY7UTDFYKMEGKW5XFJEB6PFKBF4UYSSWHG4EDH7PY")
}
func newKeypair(seed string) *keypair.Full {
myKeypair, _ := keypair.Parse(seed)
return myKeypair.(*keypair.Full)
}
func buildSignEncode(t *testing.T, tx Transaction, kps ...*keypair.Full) string {
assert.NoError(t, tx.Build())
assert.NoError(t, tx.Sign(kps...))
txeBase64, err := tx.Base64()
assert.NoError(t, err)
return txeBase64
}
func check(err error) {
if err != nil {
panic(err)
}
}
func checkChallengeTx(txeBase64, anchorName string) (bool, error) {
var txXDR xdr.TransactionEnvelope
err := xdr.SafeUnmarshalBase64(txeBase64, &txXDR)
if err != nil {
return false, err
}
op := txXDR.Tx.Operations[0]
if (xdr.OperationTypeManageData == op.Body.Type) && (op.Body.ManageDataOp.DataName == xdr.String64(anchorName+" auth")) {
return true, nil
}
return false, errors.New("invalid challenge tx")
}