mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Remove squeak detail include in squeak entry (#1837)
* Got squeak details dialog working without details rpc request * Remove get squeak detail from rpc proto * Update frontend build * Remove old get squeak detail itest * Remove unused fixture for squeak detail item
This commit is contained in:
parent
4ece90d9d2
commit
6233890e5b
19 changed files with 58 additions and 145 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useState } from 'react';
|
||||
import React from 'react';
|
||||
import {
|
||||
Typography,
|
||||
Grid,
|
||||
|
|
@ -15,9 +15,6 @@ import useStyles from './styles';
|
|||
|
||||
import Widget from '../Widget';
|
||||
|
||||
import {
|
||||
getSqueakDetailsRequest,
|
||||
} from '../../squeakclient/requests';
|
||||
|
||||
export default function SqueakDetailsDialog({
|
||||
open,
|
||||
|
|
@ -28,14 +25,8 @@ export default function SqueakDetailsDialog({
|
|||
}) {
|
||||
const classes = useStyles();
|
||||
|
||||
const [squeakDetails, setSqueakDetails] = useState(null);
|
||||
|
||||
const getSqueakDetails = (hash) => {
|
||||
getSqueakDetailsRequest(hash, setSqueakDetails);
|
||||
};
|
||||
|
||||
function load(event) {
|
||||
getSqueakDetails(hash);
|
||||
// Nothing
|
||||
}
|
||||
|
||||
function cancel(event) {
|
||||
|
|
@ -97,7 +88,21 @@ export default function SqueakDetailsDialog({
|
|||
<TextField
|
||||
id="standard-textarea"
|
||||
placeholder="Placeholder"
|
||||
value={squeakDetails.getSerializedSqueakHex()}
|
||||
value={squeak.getSerializedSqueakHex()}
|
||||
fullWidth="true"
|
||||
variant="outlined"
|
||||
multiline
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div key="rawdata" className={classes.legendItemContainer}>
|
||||
<Typography color="text" colorBrightness="secondary">
|
||||
Secret key
|
||||
</Typography>
|
||||
<TextField
|
||||
id="standard-textarea"
|
||||
placeholder="Placeholder"
|
||||
value={squeak.getSecretKeyHex()}
|
||||
fullWidth="true"
|
||||
variant="outlined"
|
||||
multiline
|
||||
|
|
@ -117,7 +122,7 @@ export default function SqueakDetailsDialog({
|
|||
<DialogTitle id="form-dialog-title">View Squeak Details</DialogTitle>
|
||||
<form className={classes.root} noValidate autoComplete="off">
|
||||
<DialogContent>
|
||||
{(squeak && squeakDetails)
|
||||
{(squeak)
|
||||
&& SqueakDetailsContent()}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ import {
|
|||
DeleteSqueakProfileRequest,
|
||||
DeleteSqueakRequest,
|
||||
DownloadSqueakRequest,
|
||||
GetSqueakDetailsRequest,
|
||||
GetSentPaymentsRequest,
|
||||
GetReceivedPaymentsRequest,
|
||||
GetNetworkRequest,
|
||||
|
|
@ -105,7 +104,6 @@ import {
|
|||
DownloadOffersReply,
|
||||
DownloadRepliesReply,
|
||||
DownloadAddressSqueaksReply,
|
||||
GetSqueakDetailsReply,
|
||||
GetSentPaymentsReply,
|
||||
GetReceivedPaymentsReply,
|
||||
GetNetworkReply,
|
||||
|
|
@ -912,22 +910,6 @@ export function downloadAddressSqueaksRequest(address, handleResponse) {
|
|||
// });
|
||||
}
|
||||
|
||||
export function getSqueakDetailsRequest(hash, handleResponse) {
|
||||
const request = new GetSqueakDetailsRequest();
|
||||
request.setSqueakHash(hash);
|
||||
makeRequest(
|
||||
'getsqueakdetails',
|
||||
request,
|
||||
GetSqueakDetailsReply.deserializeBinary,
|
||||
(response) => {
|
||||
handleResponse(response.getSqueakDetailEntry());
|
||||
},
|
||||
);
|
||||
// client.getSqueakDetails(request, {}, (err, response) => {
|
||||
// handleResponse(response.getSqueakDetailEntry());
|
||||
// });
|
||||
}
|
||||
|
||||
export function getSentPaymentsRequest(limit, lastSentPayment, handleResponse) {
|
||||
const request = new GetSentPaymentsRequest();
|
||||
request.setLimit(limit);
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ def test_make_squeak(admin_stub, signing_profile_id):
|
|||
get_squeak_display_entry.author.profile_image) > 0
|
||||
assert not get_squeak_display_entry.is_reply
|
||||
assert not bool(get_squeak_display_entry.reply_to)
|
||||
assert len(get_squeak_display_entry.secret_key_hex) == 32 * 2
|
||||
|
||||
# Block time should be within the past hour
|
||||
block_time = datetime.datetime.fromtimestamp(
|
||||
|
|
@ -210,6 +211,15 @@ def test_make_squeak(admin_stub, signing_profile_id):
|
|||
assert squeak_display_entry.author.profile_name == squeak_profile_name
|
||||
assert squeak_display_entry.author.address == squeak_profile_address
|
||||
|
||||
# check serialized squeak hex string
|
||||
serialized_squeak_hex = get_squeak_display_entry.serialized_squeak_hex
|
||||
# print("serialized_squeak_hex: {}".format(serialized_squeak_hex))
|
||||
assert len(serialized_squeak_hex) > 200
|
||||
serialized_squeak = bytes.fromhex(serialized_squeak_hex)
|
||||
deserialized_squeak = CSqueak.deserialize(serialized_squeak)
|
||||
assert get_hash(deserialized_squeak) == make_squeak_hash
|
||||
CheckSqueak(deserialized_squeak)
|
||||
|
||||
|
||||
def test_make_reply_squeak(
|
||||
admin_stub, saved_squeak_hash, signing_profile_id
|
||||
|
|
@ -896,25 +906,6 @@ def test_download_squeaks_for_address(
|
|||
assert item.squeak_hash == saved_squeak_hash
|
||||
|
||||
|
||||
def test_get_squeak_details(admin_stub, saved_squeak_hash):
|
||||
# Get the squeak details
|
||||
get_squeak_details_response = admin_stub.GetSqueakDetails(
|
||||
squeak_admin_pb2.GetSqueakDetailsRequest(
|
||||
squeak_hash=saved_squeak_hash,
|
||||
)
|
||||
)
|
||||
serialized_squeak_hex = (
|
||||
get_squeak_details_response.squeak_detail_entry.serialized_squeak_hex
|
||||
)
|
||||
# print("serialized_squeak_hex: {}".format(serialized_squeak_hex))
|
||||
assert len(serialized_squeak_hex) > 200
|
||||
|
||||
serialized_squeak = bytes.fromhex(serialized_squeak_hex)
|
||||
deserialized_squeak = CSqueak.deserialize(serialized_squeak)
|
||||
assert get_hash(deserialized_squeak) == saved_squeak_hash
|
||||
CheckSqueak(deserialized_squeak)
|
||||
|
||||
|
||||
def test_like_squeak(admin_stub, saved_squeak_hash):
|
||||
# Get the squeak display item
|
||||
get_squeak_display_entry = get_squeak_display(
|
||||
|
|
|
|||
|
|
@ -228,10 +228,6 @@ service SqueakAdmin {
|
|||
*/
|
||||
rpc GetSentPayment (GetSentPaymentRequest) returns (GetSentPaymentReply) {}
|
||||
|
||||
/** sqkadmin: `getsqueakdetails`
|
||||
*/
|
||||
rpc GetSqueakDetails (GetSqueakDetailsRequest) returns (GetSqueakDetailsReply) {}
|
||||
|
||||
/** sqkadmin: `getsentoffers`
|
||||
*/
|
||||
rpc GetSentOffers (GetSentOffersRequest) returns (GetSentOffersReply) {}
|
||||
|
|
@ -599,6 +595,12 @@ message SqueakDisplayEntry {
|
|||
|
||||
/// Liked time
|
||||
int64 liked_time_ms = 13;
|
||||
|
||||
/// The serialized squeak in hex.
|
||||
string serialized_squeak_hex = 14;
|
||||
|
||||
/// The secret key in hex.
|
||||
string secret_key_hex = 15;
|
||||
}
|
||||
|
||||
message GetTimelineSqueakDisplaysRequest {
|
||||
|
|
@ -969,21 +971,6 @@ message DownloadAddressSqueaksReply {
|
|||
DownloadResult download_result = 1;
|
||||
}
|
||||
|
||||
message GetSqueakDetailsRequest {
|
||||
/// Hash of the squeak.
|
||||
string squeak_hash = 1;
|
||||
}
|
||||
|
||||
message GetSqueakDetailsReply {
|
||||
/// The squeak detail entry
|
||||
SqueakDetailEntry squeak_detail_entry = 1;
|
||||
}
|
||||
|
||||
message SqueakDetailEntry {
|
||||
/// The seriallized squeak in hex encoding
|
||||
string serialized_squeak_hex = 1;
|
||||
}
|
||||
|
||||
message GetSentOffersRequest {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@
|
|||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from squeak.core import CSqueak
|
||||
|
||||
from proto import squeak_admin_pb2
|
||||
from squeaknode.admin.profile_image_util import bytes_to_base64_string
|
||||
from squeaknode.admin.profile_image_util import load_default_profile_image
|
||||
|
|
@ -50,6 +48,7 @@ DEFAULT_PROFILE_IMAGE = load_default_profile_image()
|
|||
|
||||
def squeak_entry_to_message(squeak_entry: SqueakEntry) -> squeak_admin_pb2.SqueakDisplayEntry:
|
||||
squeak_profile = squeak_entry.squeak_profile
|
||||
secret_key = squeak_entry.secret_key.hex() if squeak_entry.secret_key else None
|
||||
is_reply = bool(squeak_entry.reply_to)
|
||||
reply_to = squeak_entry.reply_to.hex() if squeak_entry.reply_to else None
|
||||
is_author_known = False
|
||||
|
|
@ -59,7 +58,9 @@ def squeak_entry_to_message(squeak_entry: SqueakEntry) -> squeak_admin_pb2.Squea
|
|||
profile_msg = squeak_profile_to_message(squeak_profile)
|
||||
return squeak_admin_pb2.SqueakDisplayEntry(
|
||||
squeak_hash=squeak_entry.squeak_hash.hex(),
|
||||
serialized_squeak_hex=squeak_entry.serialized_squeak.hex(),
|
||||
is_unlocked=squeak_entry.is_unlocked,
|
||||
secret_key_hex=secret_key, # type: ignore
|
||||
content_str=squeak_entry.content, # type: ignore
|
||||
block_height=squeak_entry.block_height,
|
||||
block_hash=squeak_entry.block_hash.hex(),
|
||||
|
|
@ -132,13 +133,6 @@ def sent_payment_to_message(sent_payment: SentPayment) -> squeak_admin_pb2.SentP
|
|||
)
|
||||
|
||||
|
||||
def squeak_to_detail_message(squeak: CSqueak) -> squeak_admin_pb2.SqueakDetailEntry:
|
||||
serialized_squeak = squeak.serialize()
|
||||
return squeak_admin_pb2.SqueakDetailEntry(
|
||||
serialized_squeak_hex=serialized_squeak.hex(),
|
||||
)
|
||||
|
||||
|
||||
def sent_offer_to_message(sent_offer: SentOffer) -> squeak_admin_pb2.SentOffer:
|
||||
sent_offer_id = sent_offer.sent_offer_id or 0
|
||||
return squeak_admin_pb2.SentOffer(
|
||||
|
|
@ -214,8 +208,11 @@ def message_to_squeak_entry(msg: squeak_admin_pb2.SqueakDisplayEntry) -> SqueakE
|
|||
like_time_ms = msg.liked_time_ms if msg.liked_time_ms > 0 else None
|
||||
reply_to_hash = bytes.fromhex(msg.reply_to) if msg.reply_to else None
|
||||
content_str = msg.content_str if len(msg.content_str) > 0 else None
|
||||
secret_key = bytes.fromhex(
|
||||
msg.secret_key_hex) if msg.secret_key_hex else None
|
||||
return SqueakEntry(
|
||||
squeak_hash=bytes.fromhex(msg.squeak_hash),
|
||||
serialized_squeak=bytes.fromhex(msg.serialized_squeak_hex),
|
||||
address=msg.author_address,
|
||||
block_height=msg.block_height,
|
||||
block_hash=bytes.fromhex(msg.block_hash),
|
||||
|
|
@ -223,6 +220,7 @@ def message_to_squeak_entry(msg: squeak_admin_pb2.SqueakDisplayEntry) -> SqueakE
|
|||
squeak_time=msg.squeak_time,
|
||||
reply_to=reply_to_hash,
|
||||
is_unlocked=msg.is_unlocked,
|
||||
secret_key=secret_key,
|
||||
squeak_profile=None, # TODO: message to squeak profile
|
||||
liked_time_ms=like_time_ms,
|
||||
content=content_str,
|
||||
|
|
@ -318,12 +316,6 @@ def optional_sent_payment_to_message(sent_payment: Optional[SentPayment]) -> Opt
|
|||
return sent_payment_to_message(sent_payment)
|
||||
|
||||
|
||||
def optional_squeak_to_detail_message(squeak: Optional[CSqueak]) -> Optional[squeak_admin_pb2.SqueakDetailEntry]:
|
||||
if squeak is None:
|
||||
return None
|
||||
return squeak_to_detail_message(squeak)
|
||||
|
||||
|
||||
def optional_connected_peer_to_message(connected_peer: Optional[ConnectedPeer]) -> Optional[squeak_admin_pb2.ConnectedPeer]:
|
||||
if connected_peer is None:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ from squeaknode.admin.messages import optional_squeak_entry_to_message
|
|||
from squeaknode.admin.messages import optional_squeak_hash_to_hex
|
||||
from squeaknode.admin.messages import optional_squeak_peer_to_message
|
||||
from squeaknode.admin.messages import optional_squeak_profile_to_message
|
||||
from squeaknode.admin.messages import optional_squeak_to_detail_message
|
||||
from squeaknode.admin.messages import payment_summary_to_message
|
||||
from squeaknode.admin.messages import peer_address_to_message
|
||||
from squeaknode.admin.messages import received_offer_to_message
|
||||
|
|
@ -704,21 +703,6 @@ class SqueakAdminServerHandler(object):
|
|||
sent_payment=sent_payment_msg,
|
||||
)
|
||||
|
||||
def handle_get_squeak_details(self, request: squeak_admin_pb2.GetSqueakDetailsRequest):
|
||||
squeak_hash_str = request.squeak_hash
|
||||
squeak_hash = bytes.fromhex(squeak_hash_str)
|
||||
logger.info(
|
||||
"Handle get squeak details for hash: {}".format(squeak_hash_str))
|
||||
squeak = (
|
||||
self.squeak_controller.get_squeak(
|
||||
squeak_hash
|
||||
)
|
||||
)
|
||||
detail_message = optional_squeak_to_detail_message(squeak)
|
||||
return squeak_admin_pb2.GetSqueakDetailsReply(
|
||||
squeak_detail_entry=detail_message
|
||||
)
|
||||
|
||||
def handle_get_sent_offers(self, request):
|
||||
logger.info("Handle get sent offers")
|
||||
sent_offers = self.squeak_controller.get_sent_offers()
|
||||
|
|
|
|||
|
|
@ -215,9 +215,6 @@ class SqueakAdminServerServicer(squeak_admin_pb2_grpc.SqueakAdminServicer):
|
|||
def GetSentPayment(self, request, context):
|
||||
return self.handler.handle_get_sent_payment(request)
|
||||
|
||||
def GetSqueakDetails(self, request, context):
|
||||
return self.handler.handle_get_squeak_details(request)
|
||||
|
||||
def GetSentOffers(self, request, context):
|
||||
return self.handler.handle_get_sent_offers(request)
|
||||
|
||||
|
|
|
|||
|
|
@ -415,12 +415,6 @@ def create_app(handler, username, password):
|
|||
def downloadaddresssqueaks(msg):
|
||||
return handler.handle_download_address_squeaks(msg)
|
||||
|
||||
@app.route("/getsqueakdetails", methods=["POST"])
|
||||
@login_required
|
||||
@protobuf_serialized(squeak_admin_pb2.GetSqueakDetailsRequest())
|
||||
def getsqueakdetails(msg):
|
||||
return handler.handle_get_squeak_details(msg)
|
||||
|
||||
@app.route("/getsentpayments", methods=["POST"])
|
||||
@login_required
|
||||
@protobuf_serialized(squeak_admin_pb2.GetSentPaymentsRequest())
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"files": {
|
||||
"main.js": "/static/js/main.7cfc402f.chunk.js",
|
||||
"main.js.map": "/static/js/main.7cfc402f.chunk.js.map",
|
||||
"main.js": "/static/js/main.8e95e06e.chunk.js",
|
||||
"main.js.map": "/static/js/main.8e95e06e.chunk.js.map",
|
||||
"runtime-main.js": "/static/js/runtime-main.48a1d1b9.js",
|
||||
"runtime-main.js.map": "/static/js/runtime-main.48a1d1b9.js.map",
|
||||
"static/css/2.f68b60d4.chunk.css": "/static/css/2.f68b60d4.chunk.css",
|
||||
|
|
@ -18,6 +18,6 @@
|
|||
"static/js/runtime-main.48a1d1b9.js",
|
||||
"static/css/2.f68b60d4.chunk.css",
|
||||
"static/js/2.92034823.chunk.js",
|
||||
"static/js/main.7cfc402f.chunk.js"
|
||||
"static/js/main.8e95e06e.chunk.js"
|
||||
]
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><meta name="description" content="Squeaknode is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.f68b60d4.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.92034823.chunk.js"></script><script src="/static/js/main.7cfc402f.chunk.js"></script></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><meta name="description" content="Squeaknode is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.f68b60d4.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.92034823.chunk.js"></script><script src="/static/js/main.8e95e06e.chunk.js"></script></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -27,6 +27,7 @@ from squeaknode.core.squeak_profile import SqueakProfile
|
|||
|
||||
class SqueakEntry(NamedTuple):
|
||||
squeak_hash: bytes
|
||||
serialized_squeak: bytes
|
||||
address: str
|
||||
block_height: int
|
||||
block_hash: bytes
|
||||
|
|
@ -34,6 +35,7 @@ class SqueakEntry(NamedTuple):
|
|||
squeak_time: int
|
||||
reply_to: Optional[bytes]
|
||||
is_unlocked: bool
|
||||
secret_key: Optional[bytes]
|
||||
squeak_profile: Optional[SqueakProfile]
|
||||
liked_time_ms: Optional[int] = None
|
||||
content: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -1461,6 +1461,7 @@ class SqueakDb:
|
|||
profile = self._try_parse_squeak_profile(row)
|
||||
return SqueakEntry(
|
||||
squeak_hash=(row["hash"]),
|
||||
serialized_squeak=(row["squeak"]),
|
||||
address=row["author_address"],
|
||||
block_height=row["n_block_height"],
|
||||
block_hash=(row["hash_block"]),
|
||||
|
|
@ -1468,6 +1469,7 @@ class SqueakDb:
|
|||
squeak_time=row["n_time"],
|
||||
reply_to=reply_to,
|
||||
is_unlocked=is_locked,
|
||||
secret_key=(row["secret_key"]),
|
||||
liked_time_ms=liked_time_ms,
|
||||
content=row["content"],
|
||||
squeak_profile=profile,
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ def signing_profile_msg(
|
|||
@pytest.fixture
|
||||
def squeak_entry_msg_locked(
|
||||
squeak,
|
||||
squeak_bytes,
|
||||
squeak_hash,
|
||||
address_str,
|
||||
block_count,
|
||||
|
|
@ -71,7 +72,9 @@ def squeak_entry_msg_locked(
|
|||
):
|
||||
yield squeak_admin_pb2.SqueakDisplayEntry(
|
||||
squeak_hash=squeak_hash.hex(),
|
||||
serialized_squeak_hex=squeak_bytes.hex(),
|
||||
is_unlocked=False,
|
||||
secret_key_hex="",
|
||||
content_str=None, # type: ignore
|
||||
block_height=block_count,
|
||||
block_hash=block_hash.hex(),
|
||||
|
|
@ -175,15 +178,6 @@ def sent_payment_msg(
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def squeak_detail_msg(
|
||||
squeak_bytes,
|
||||
):
|
||||
yield squeak_admin_pb2.SqueakDetailEntry(
|
||||
serialized_squeak_hex=squeak_bytes.hex(),
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def payment_summary_msg(
|
||||
num_received_payments,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ from squeaknode.admin.messages import optional_squeak_entry_to_message
|
|||
from squeaknode.admin.messages import optional_squeak_hash_to_hex
|
||||
from squeaknode.admin.messages import optional_squeak_peer_to_message
|
||||
from squeaknode.admin.messages import optional_squeak_profile_to_message
|
||||
from squeaknode.admin.messages import optional_squeak_to_detail_message
|
||||
from squeaknode.admin.messages import payment_summary_to_message
|
||||
from squeaknode.admin.messages import peer_address_to_message
|
||||
from squeaknode.admin.messages import received_offer_to_message
|
||||
|
|
@ -42,7 +41,6 @@ from squeaknode.admin.messages import sent_payment_to_message
|
|||
from squeaknode.admin.messages import squeak_entry_to_message
|
||||
from squeaknode.admin.messages import squeak_peer_to_message
|
||||
from squeaknode.admin.messages import squeak_profile_to_message
|
||||
from squeaknode.admin.messages import squeak_to_detail_message
|
||||
|
||||
|
||||
def test_peer_address_to_message(peer_address, peer_address_message):
|
||||
|
|
@ -131,12 +129,6 @@ def test_message_to_sent_payment(sent_payment, sent_payment_msg):
|
|||
assert decoded_sent_payment == sent_payment_with_empty_secret_key
|
||||
|
||||
|
||||
def test_squeak_detail_to_message(squeak, squeak_detail_msg):
|
||||
msg = squeak_to_detail_message(squeak)
|
||||
|
||||
assert msg == squeak_detail_msg
|
||||
|
||||
|
||||
def test_payment_summary_to_message(
|
||||
received_payment_summary,
|
||||
sent_payment_summary,
|
||||
|
|
@ -228,18 +220,6 @@ def test_optional_sent_payment_to_message(sent_payment, sent_payment_msg):
|
|||
assert msg == sent_payment_msg
|
||||
|
||||
|
||||
def test_optional_squeak_detail_to_message_none():
|
||||
msg = optional_squeak_to_detail_message(None)
|
||||
|
||||
assert msg is None
|
||||
|
||||
|
||||
def test_optional_squeak_detail_to_message(squeak, squeak_detail_msg):
|
||||
msg = optional_squeak_to_detail_message(squeak)
|
||||
|
||||
assert msg == squeak_detail_msg
|
||||
|
||||
|
||||
def test_optional_connected_peer_to_message_none():
|
||||
msg = optional_connected_peer_to_message(None)
|
||||
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ def contact_profile(contact_profile_name, address):
|
|||
@pytest.fixture
|
||||
def squeak_entry_locked(
|
||||
squeak,
|
||||
squeak_bytes,
|
||||
squeak_hash,
|
||||
address_str,
|
||||
block_count,
|
||||
|
|
@ -246,6 +247,7 @@ def squeak_entry_locked(
|
|||
):
|
||||
yield SqueakEntry(
|
||||
squeak_hash=squeak_hash,
|
||||
serialized_squeak=squeak_bytes,
|
||||
address=address_str,
|
||||
block_height=block_count,
|
||||
block_hash=block_hash,
|
||||
|
|
@ -253,6 +255,7 @@ def squeak_entry_locked(
|
|||
squeak_time=squeak_time,
|
||||
reply_to=squeak_reply_to_hash,
|
||||
is_unlocked=False,
|
||||
secret_key=None,
|
||||
squeak_profile=signing_profile,
|
||||
liked_time_ms=None,
|
||||
content=None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue