mirror of
https://github.com/unclebob/more-speech.git
synced 2024-09-30 02:21:02 +00:00
fixed a silently passing bug in one of the zap tests.
This commit is contained in:
parent
13445a937e
commit
e191d9e5c3
@ -103,7 +103,8 @@
|
||||
(with zap-descriptor {:zap-amount 1000
|
||||
:zap-comment "12345678901234567890"
|
||||
:id 1
|
||||
:pubkey 99})
|
||||
:pubkey 99
|
||||
:auto-zap? true})
|
||||
|
||||
(it "makes a zap request if all is valid"
|
||||
(with-redefs [util/get-now (stub :get-now {:return 11111})]
|
||||
@ -206,12 +207,15 @@
|
||||
(context "wallet-connect"
|
||||
(it "executes wallet-connect payment"
|
||||
(let [event-index (atom -1)
|
||||
events [{:content "pay_invoice"} {:kind 23195 :content "{\"result_type\": \"pay_invoice\"}"}]]
|
||||
events [{:content "pay_invoice"} {:kind 23195
|
||||
:tags [[:p "e6c47ae6962c5ea1559f48b437c193a1bcb1d72d08d75d743ba3cbfb8e7afbeb"]]
|
||||
:content "{\"result_type\": \"pay_invoice\"}"}]]
|
||||
(set-mem [:keys :wallet-connect] "nostrwalletconnect://beef?relay=wc-relay-url&secret=dead")
|
||||
(with-redefs [ws-relay/make (stub :relay-make {:return "some-relay"})
|
||||
relay/open (stub :relay-open {:return "open-relay"})
|
||||
relay/send (stub :relay-send)
|
||||
relay/close (stub :relay-close)
|
||||
zaps/decrypt-content (stub :calc-key {:invoke (fn [_ _ c] c)})
|
||||
zaps/get-wc-request-event (stub :request-event {:return "request-event"})
|
||||
async/<!! (stub :read-chan {:invoke (fn [_x] (get events (swap! event-index inc)))})]
|
||||
(let [event-chan :some-channel]
|
||||
|
@ -240,6 +240,10 @@
|
||||
request (make-wc-json-request invoice)]
|
||||
(compose-wc-request-event wc-pubkey-hex secret-hex request)))
|
||||
|
||||
(defn decrypt-content [secret wc-pubkey content]
|
||||
(let [shared-secret (SECP256K1/calculateKeyAgreement secret wc-pubkey)]
|
||||
(SECP256K1/decrypt shared-secret content)))
|
||||
|
||||
(defn zap-by-wallet-connect
|
||||
([zap-descriptor]
|
||||
(zap-by-wallet-connect zap-descriptor (async/timeout 60000)))
|
||||
@ -262,8 +266,7 @@
|
||||
ptag (ffirst (events/get-tag response-event :p))]
|
||||
(if-not (= ptag secret-pubkey-hex)
|
||||
:continue
|
||||
(let [shared-secret (SECP256K1/calculateKeyAgreement secret wc-pubkey)
|
||||
decrypted-content (SECP256K1/decrypt shared-secret content)
|
||||
(let [decrypted-content (decrypt-content secret wc-pubkey content)
|
||||
response (json/read-str decrypted-content)
|
||||
result-type (get response "result_type")
|
||||
error (get response "error")]
|
||||
|
Loading…
Reference in New Issue
Block a user