mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
tweak
This commit is contained in:
parent
2ac026780b
commit
e6246c48ce
1 changed files with 27 additions and 20 deletions
|
|
@ -1065,6 +1065,7 @@ func TestEncodeDataRecursiveBytes(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSignInWithEtheriumValidLocalhost(t *testing.T) {
|
func TestSignInWithEtheriumValidLocalhost(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tests := map[string]string{
|
tests := map[string]string{
|
||||||
"argent": "http://localhost:4361 wants you to sign in with your Ethereum account:\n{{Account}}\n\nSIWE Notepad Example\n\nURI: http://localhost:4361\nVersion: 1\nChain ID: 1\nNonce: FbYd6TNB4m0IUHDG7\nIssued At: 2022-04-19T18:55:04.444Z",
|
"argent": "http://localhost:4361 wants you to sign in with your Ethereum account:\n{{Account}}\n\nSIWE Notepad Example\n\nURI: http://localhost:4361\nVersion: 1\nChain ID: 1\nNonce: FbYd6TNB4m0IUHDG7\nIssued At: 2022-04-19T18:55:04.444Z",
|
||||||
"loopring": "http://localhost:4361 wants you to sign in with your Ethereum account:\n{{Account}}\n\nSIWE Notepad Example\n\nURI: http://localhost:4361\nVersion: 1\nChain ID: 1\nNonce: b19JyMHnM0Jdm20as\nIssued At: 2022-04-19T18:57:09.490Z",
|
"loopring": "http://localhost:4361 wants you to sign in with your Ethereum account:\n{{Account}}\n\nSIWE Notepad Example\n\nURI: http://localhost:4361\nVersion: 1\nChain ID: 1\nNonce: b19JyMHnM0Jdm20as\nIssued At: 2022-04-19T18:57:09.490Z",
|
||||||
|
|
@ -1072,7 +1073,6 @@ func TestSignInWithEtheriumValidLocalhost(t *testing.T) {
|
||||||
|
|
||||||
for testName, msg := range tests {
|
for testName, msg := range tests {
|
||||||
t.Run(testName, func(t *testing.T) {
|
t.Run(testName, func(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
api, control := setup(t, true)
|
api, control := setup(t, true)
|
||||||
createAccount(control, api, t)
|
createAccount(control, api, t)
|
||||||
createAccount(control, api, t)
|
createAccount(control, api, t)
|
||||||
|
|
@ -1097,6 +1097,7 @@ func TestSignInWithEtheriumValidLocalhost(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSignInWithEtheriumValidMessages(t *testing.T) {
|
func TestSignInWithEtheriumValidMessages(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
jsonFile, err := os.ReadFile(filepath.Join("testdata", "siwe", "valid_messages.json"))
|
jsonFile, err := os.ReadFile(filepath.Join("testdata", "siwe", "valid_messages.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
tests := make(map[string]string)
|
tests := make(map[string]string)
|
||||||
|
|
@ -1104,7 +1105,6 @@ func TestSignInWithEtheriumValidMessages(t *testing.T) {
|
||||||
|
|
||||||
for testName, msg := range tests {
|
for testName, msg := range tests {
|
||||||
t.Run(testName, func(t *testing.T) {
|
t.Run(testName, func(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
api, control := setup(t, true)
|
api, control := setup(t, true)
|
||||||
createAccount(control, api, t)
|
createAccount(control, api, t)
|
||||||
createAccount(control, api, t)
|
createAccount(control, api, t)
|
||||||
|
|
@ -1130,6 +1130,7 @@ func TestSignInWithEtheriumValidMessages(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSignInWithEtheriumInvlid(t *testing.T) {
|
func TestSignInWithEtheriumInvlid(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var tests map[string]struct {
|
var tests map[string]struct {
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
RequestContext struct {
|
RequestContext struct {
|
||||||
|
|
@ -1143,9 +1144,10 @@ func TestSignInWithEtheriumInvlid(t *testing.T) {
|
||||||
require.NoError(t, json.Unmarshal(jsonFile, &tests))
|
require.NoError(t, json.Unmarshal(jsonFile, &tests))
|
||||||
|
|
||||||
for testName, testData := range tests {
|
for testName, testData := range tests {
|
||||||
t.Run(testName, func(t *testing.T) {
|
for _, enabled := range []bool{true, false} {
|
||||||
t.Parallel()
|
t.Run(fmt.Sprintf("%s-%t", testName, enabled), func(t *testing.T) {
|
||||||
api, control := setup(t, true)
|
// t.Parallel()
|
||||||
|
api, control := setup(t, enabled)
|
||||||
createAccount(control, api, t)
|
createAccount(control, api, t)
|
||||||
createAccount(control, api, t)
|
createAccount(control, api, t)
|
||||||
control.approveCh <- "1"
|
control.approveCh <- "1"
|
||||||
|
|
@ -1160,12 +1162,18 @@ func TestSignInWithEtheriumInvlid(t *testing.T) {
|
||||||
control.approveCh <- "Y"
|
control.approveCh <- "Y"
|
||||||
control.inputCh <- "a_long_password"
|
control.inputCh <- "a_long_password"
|
||||||
_, err = api.SignData(ctx, apitypes.TextPlain.Mime, a, hexutil.Encode([]byte(message)))
|
_, err = api.SignData(ctx, apitypes.TextPlain.Mime, a, hexutil.Encode([]byte(message)))
|
||||||
|
if enabled {
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
} else {
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSignInWithEtheriumWarning(t *testing.T) {
|
func TestSignInWithEtheriumWarning(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
jsonFile, err := os.ReadFile(filepath.Join("testdata", "siwe", "warnings.json"))
|
jsonFile, err := os.ReadFile(filepath.Join("testdata", "siwe", "warnings.json"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
tests := make(map[string]string)
|
tests := make(map[string]string)
|
||||||
|
|
@ -1173,7 +1181,6 @@ func TestSignInWithEtheriumWarning(t *testing.T) {
|
||||||
|
|
||||||
for testName, msg := range tests {
|
for testName, msg := range tests {
|
||||||
t.Run(testName, func(t *testing.T) {
|
t.Run(testName, func(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
api, control := setup(t, true)
|
api, control := setup(t, true)
|
||||||
createAccount(control, api, t)
|
createAccount(control, api, t)
|
||||||
createAccount(control, api, t)
|
createAccount(control, api, t)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue