patch 9.0.1583: get E304 when using 'cryptmethod' "xchacha20v2"
Problem: Get E304 when using 'cryptmethod' "xchacha20v2". (Steve Mynott)
Solution: Add 4th crypt method to block zero ID check. Avoid syncing a swap
file before reading the file. (closes #12433)
diff --git a/src/testdir/test_crypt.vim b/src/testdir/test_crypt.vim
index 265cc83..cb94c18 100644
--- a/src/testdir/test_crypt.vim
+++ b/src/testdir/test_crypt.vim
@@ -1,5 +1,6 @@
" Tests for encryption.
+source shared.vim
source check.vim
CheckFeature cryptv
@@ -88,6 +89,29 @@
call Crypt_uncrypt('xchacha20v2')
endfunc
+func Test_crypt_sodium_v2_startup()
+ CheckFeature sodium
+ CheckRunVimInTerminal
+
+ let buf = RunVimInTerminal('--cmd "set cm=xchacha20v2" -x Xfoo', #{wait_for_ruler: 0, rows: 6})
+ call g:TermWait(buf, g:RunningWithValgrind() ? 1000 : 50)
+ call term_sendkeys(buf, "foo\<CR>foo\<CR>")
+ call term_sendkeys(buf, "ifoo\<Esc>")
+ call term_sendkeys(buf, "ZZ")
+ call TermWait(buf)
+
+ " Wait for Vim to write the file and exit. Then wipe out the terminal buffer.
+ call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))})
+ exe buf .. 'bwipe!'
+ call assert_true(filereadable('Xfoo'))
+
+ let buf = RunVimInTerminal('--cmd "set ch=3 cm=xchacha20v2 key=foo" Xfoo', #{rows: 10})
+ call g:TermWait(buf, g:RunningWithValgrind() ? 1000 : 50)
+ call StopVimInTerminal(buf)
+
+ call delete('Xfoo')
+endfunc
+
func Uncrypt_stable(method, crypted_text, key, uncrypted_text)
split Xtest.txt
set bin noeol key= fenc=latin1